PragmaticBookshelf

PragmaticBookshelf

Forum Sponsor

Northwind Elixir Traders (PragProg)

Isaak Tsalicoglou

Built for the curious, this isn’t your average programming book—it’s nearly 500 pages of hands-on mentorship beyond coding, fusing core skills in Elixir, Ecto, and SQLite with business experience and R&D tenacity. Think of it as a $500 course distilled into one powerhouse resource, with tons of learning-by-doing, in a single project. Acquire hard skills in Elixir and database modeling with Ecto’s migrations, changesets, and more, re-imagining a classic database that millions around the world have used before for learning. By fearlessly ditching the “happy path”, this immersive, exploratory, memorable, project-based tutorial helps you confidently tackle real-world projects with Elixir and Ecto.

Built for the curious, Northwind Elixir Traders isn’t your typical programming tutorial. This immersive, project-based adventure reimagines the classic Northwind database, guiding you through Ecto’s migrations, changesets, and queries to model data with real-world edge. Ditching the “happy path,” it’s one ambitious journey—crafting a schema step by step, wrestling with SQLite’s quirks, and automating bulk imports, all while sharpening Elixir skills via side-quests like refactoring and systematic problem-solving. Drawing from the author’s R&D and B2B equipment-trading experience, it’s nearly 500 pages of hands-on mentorship—think Elixir gym crossed with an engineer’s playground.

You’ll transform an Entity Relationship Diagram into code, tame messy data, and unearth insights with queries both simple and complex. It’s not about exhausting Ecto’s every nook; it’s about grokking the essentials through practice, fearless experimentation, and diving into docs when things don’t work according to intuition or expectation. SQLite spices up the challenge, but the skills you’ll build also apply to working with PostgreSQL. Sprinkled with mini-essays from the author’s experience, it builds a gritty mindset to confidently tackle real-world projects—no copy-paste prayers needed. For Elixir newcomers, database dabblers, or those looking to build the data foundation of their Phoenix LiveView app, this is a speed-run in upskilling, wrapped in an enjoyable and unforgettable exploration.

This work was written and produced entirely by the author. We are proud to be distributing it.


Isaak Tsalicoglou is a mechanical engineer, management consultant, and software engineer. After a corporate decade in Machine Learning in turbocharger R&D, development processes, and product management of portable radar devices, since 2020 he has been managing SaaS and B2B trading businesses in Greece, and developing open-source and commercial software in Elixir, Python, Go, PHP, and NextJS.


Full details: Northwind Elixir Traders: Learn Elixir and database modeling with Ecto and SQLite, all in one project by Isaak Tsalicoglou


Don’t forget you can get 35% off with your Devtalk discount! Just use the coupon code “devtalk.com" at checkout :+1:

Most Liked

waseigo

waseigo

Edit: Please note this book is now distributed by PragProg so the contents of the old thread (this post, all the way down to this post) have been merged into this new thread.


by Isaak Tsalicoglou

Available as PDF and ePub on Leanpub.


Why this book is being written

After reading everything I could get my hands on regarding the use of Ecto and applying what I was learning in my own Elixir and Phoenix LiveView applications, I realized that even the best books, such as “Programming Ecto”, though excellent otherwise, do not reflect the way I prefer to learn.

I started writing this book to provide an alternative take to learning about Ecto, and leave no stone unturned. By not pursuing the “happy path” of how things are done correctly from the start, I decided to start my exploration of Ecto from scratch and deal with all the stumbling blocks as they arise, by trying out what I thought might work, and referring to the amazing documentation to get unstuck.

In truth, I find that this is the way most of us learn something for good; the style of this book is a reflection of that belief, from my own experience learning everything I’ve ever studied that deserves aiming for a solid understanding–and Ecto most certainly deserves this!

About the book

Northwind Elixir Traders isn’t your typical Ecto tutorial. Instead of pursuing the usual “happy path” reflected in the official documentation and “Getting Started” guide, we’ll dive into the complexities and nuances of database implementation, offering a refreshing exploration that goes beyond the ordinary, while also relying heavily on available sources of knowledge to understand how things work from the ground up, while also moving forward without getting caught in quagmires.

Discover the joy of experimentation as we encounter unexpected hurdles and exercize our Elixir skills in figuring out why things don’t work as expected, and how to still get things done, regardless. Through these challenges, you’ll gain invaluable insights into problem-solving and critical thinking with Elixir and Ecto.

For a curious Elixir newcomer delving into the world of building databases for a microservice, a backend, or a Phoenix or Phoenix LiveView app, “Northwind Elixir Traders” promises an immersive learning experience that aims to be both enriching and unforgettable.

What’s inside

The book was first published in a Work-In-Progress state on Leanpub on April 1st, 2024. It iwll continue to be updated every week until the full envisioned scope is realized. The chapters released so far cover the creation of an application with an SQLite3-backed Ecto repository, the overview of the classic Northwind Traders database schema, the first steps of the creation of the database tables, the refinement of table schemas, and the use of schemaless changesets and validation functions.

Here is a non-exhaustive, prospective list of the topics that will be covered in chapters coming soon, some of which are already in development:

  • Changesets with schemas (up next!)
  • One-to-one, one-to-many, and many-to-one relationships between tables
  • Adding data with associations between tables
  • Queries in general
  • Queries with window functions to summarize data
  • Embedded schemas
  • Seeding the database
  • Grouping multiple repository operations
  • Enums for field values
  • Custom fields types
  • Switching to PostgreSQL

About the author

Isaak Tsalicoglou is a mechanical engineer with extensive experience in developing software tools for engineering and business use cases, and has gone all-in on Elixir since late 2022.

For a limited time only, elixirforum.com readers can get 20% off the minimum price with the following coupon link: https://leanpub.com/northwind-elixir-traders/c/elixirforum

Edit: Many thanks and apologies for catching the 406 error – I have updated the coupon link and it now verifiably works.

20
Post #2
waseigo

waseigo

Hello and welcome to version 1.0 of Northwind Elixir Traders – now with a new subtitle!

Since the last update:

  • Chapter 16 was written from scratch. We now have complex (complicated) queries that use Common Table Expressions and ROWS in a window fragment to perform window-aggregate calculations for rolling and running (sliding and expanding) windows across sequential and unique dates of dataset with triple partitioning–even for those dates that have no orders. There is also a lot of exploration of SQLite’s troubles with complex queries of that kind, as well as a section on profiling database queries with SQLite’s EXPLAIN QUERY PLAN (and with Elixir and Erlang’s :timer module) to determine what’s causing them to run slow.
  • Chapter 17 (“Leftover bits and pieces”) was dropped, since it seemed too “poor”, especially for a closing chapter. After reviewing the book in its entirety, I concluded that everything that was supposed to be in there was either truly trivial (Ecto.Enum, redacting fields, and one-to-one associations) compared to what the book has covered in almost 500 pages, or was always truly beyond the scope of the book (switching to PostgreSQL, which shouldn’t pose an issue given how everything has been implemented).
  • With a handful of exceptions, now all Elixir, Ecto and SQLite functions have been hyperlinked to their online documentation. I considered hyperlinking the book contents to the git commits, but after trying it out I found that it made already-busy book pages even busier, hindering readability.

With this, the book is now 100% complete!

For those of who have have been asking me for the complete codebase, it’s now available and Apache-2.0 licensed: GitHub - waseigo/northwind_elixir_traders: The official repository of the "Northwind Elixir Traders" book. Every code block and every instruction to change something to the code corresponds to a git commit. The commit title is the title of the corresponding code block, or a snippet of the text with the instruction on what to change/remove.

The entirety of the book has now been “replayed”–that’s how the git repo has been built from scratch by following the book step by step. Still, to err is human, so should you get stuck anywhere, please let me know.

Thank you again for your patronage and for those of you who have contributed comments and suggestions, asked questions, and requested clarifications. It has made the book way better than I ever imagined!

The next step in the story of this book is the upcoming episode of the Elixir Mentor podcast (Podcast · Elixir Mentor) with Jacob Luetzow (jacobluetzow). We’ll record it on March 21st.

The next step for me, Elixir, and writing technical books is the upcoming and much shorter Elixir Chatbot Alchemy, in which we will follow a similar exploratory approach to develop a self-hosted chatbot with Elixir, the Ollama REST API, Ecto, and Phoenix LiveView under the severe constraint of getting a decent chatbot working with only CPU-based inference.

If you enjoyed the book (or even if you didn’t!), drop me an email or contact me here–I look forward to hearing what you liked, what you didn’t, and anything else you’d like to share!

Best regards,
Isaak

waseigo

waseigo

Hello everyone and Happy New Year!

I hope that 2025 finds you healthy and personally and professionally fulfilled, and ideally with more Elixir coding than in other programming languages :slight_smile:

As Northwind Elixir Traders is nearing completion, I have reworked the first 12 chapters, fixed various typos, added clarifications, and improved the wording in a few sections. The PDF file is now generated with a new theme and a smaller (and more consistent) font size that affords more space for code on each page.

The latest version includes Chapter 13 on tying some loose ends created by an oversimplified prioritization algorithm in an earlier chapter, for determining the order of importing (or tearing down) tables with the DataImporter module’s functions. Though not central to working with databases, we debug and fix the prioritize/0 function by reimplementing it with a Depth-First Search algorithm on the following graph of dependencies between the tables of the ERD of Northwind Traders:

The next chapter drops within the next week and will be covering Ecto queries.

Until then, cheers from Greece,
Isaak

waseigo

waseigo

Hello everyone,

First off, apologies for this update taking longer than usual, even despite my recent expectation that this update would come earlier, rather than later in last week. Life got in the way, and then I also got stuck with attempting to implement a clever-and-complicated solution to one of the things in this chapter using Enum.reduce_while/3 (after learning some cool things while working on IdenticonSvg, I unsuccessfully tried to construct a dependency tree between tables).

Still, this update is a medium-large one. 37 new pages have been added, and they cover using a dynamic Ecto repository to temporarily connect to a different SQLite database, inserting data in bulk, and various bits and pieces of Elixir that aren’t directly related to Ecto, but useful when writing Elixir applications and avoiding the hard-coding of data within them, regardless, such as the :application, Application and Module modules, the Kernel.apply/3 function, and the use of the __MODULE__ attribute.

With half of the tables having been modeled to a satisfactory degree over the past 9 chapters, the content of this chapter finally allows us to gradually import data from the original Northwind Traders database to tables as we gradually model them. With some laziness-driven automation through the DataImporter module, this will make such tasks in the next chapters fly by.

In the next chapters we can proceed with modeling the rest of the tables rapidly. My interim goal is to have all of the original dataset imported, and thus be able to execute queries both complex and simple. After the “basic” task of having the entire database implemented using Ecto, the goal is to branch out and explore the fringes a bit; consider improvements to the database to take it further, using embedded schemas and Enums, and other nooks and crannies of Ecto.

I’ve marked the completion degree as 28% but it’s closer to 75% realistically. Then again… famous last words. Pretty sure that the head shall meet the desk percussively and repeatedly many times over the next weeks.

As always, your feedback is welcome!

And, if you’re enjoying the book, I would appreciate if you would leave a comment on this thread, share a link to https://leanpub.com/northwind-elixir-traders on the social network of your preference, or anything else that you find meaningful to get more people to get the book and provide feedback.

Cheers,
Isaak

waseigo

waseigo

Hello there, Elixir, Ecto and SQLite fans,

A new version of the book was just published! It includes the all-new Chapter 8 on implementing one-to-many associations with the macros of Ecto.Schema. I’ve also updated the subtitle and cover of the book by including the terms Elixir, Ecto and SQLite, to make it easier to find online.

Here’s the ToC excerpt for this new chapter:

In this chapter, we advance our understanding of table associations using the has_many/3 and belongs_to/3 macros of Ecto.Schema. We explore the N+1 query problem, the significant impact of “non-lazy loading” of associated data on our queries, and how Ecto aids in avoiding it. We then transfer our efforts from the Supplier module to enhancing the Categories module, establishing the Product module’s association through two one-to-many relationships and their inverse associations providing access to a :products field on the associated tables` records fetched with Ecto.

However, there are pending tasks to complete in these modules for full functionality during data insertion or update with associations. These tasks, including the use of build_assoc and cast_assoc, will be addressed in Chapter 9. Its target will be to enable importing of data from the original Northwind Traders database’s Products, Suppliers, and Categories tables into our Northwind Elixir Traders database, which will allow us to get into learning about basic Ecto queries in later chapters.

There is still a lot of ground to cover, so I’m marking the “gut-feeling” completeness ratio at 23%.

I would like to thank everyone who has provided feedback and encouragement! As a thank-you to this great community and to respect the earliest adopter of the book, I have just updated the “elixirforum” code to provide a 10% discount on the minimum price for the next 15 readers who take advantage ot this code:

10% off with coupon code “elixirforum” on Leanpub

As always, you can reach me on LinkedIn and by email at isaak@overbring.com.

Enjoy!
Isaak

Where Next?

Popular in Books Top

PragmaticBookshelf
Ellie Fairholm and Josep Giralt D’Lacoste edited by Nicole Tache The days of separate dev and ops teams are over—knowledge silos and the...
New
AstonJ
by Martin Logan, Eric Merritt, and Richard Carlsson Erlang and OTP in Action teaches you the concepts of concurrent programming and the ...
New
PragmaticBookshelf
Frank Hunleth @fhunleth Bruce A. Tate @redrapids edited by Jacquelyn Carter @jkcarter Want to get better at coding Elixir? Write a har...
New
wintermeyer
At https://elixir-phoenix-ash.com I publish training material for Elixir and Phoenix. Text base tutorials which start at zero. Recently I...
New
PragmaticBookshelf
Sean Moriarity @seanmor5 edited by Tammy Coron @Paradox927 Stable Diffusion, ChatGPT, Whisper—these are just a few examples of incredibl...
New
PragmaticBookshelf
Peter Ullrich (@PJUllrich) edited by Michael Swaine @michaelswaine Data is at the core of every business, but it is useless if nobody ca...
New
vincentvanbush
Hey! Happy to announce the Elixir Adoption Guide by Curiosum, announced during this year’s ElixirConf EU, is out to the public now :slig...
New
peerreynders
by Darin Wilson and Eric Meadows-Jönsson Languages may come and go, but the relational database endures. Learn how to use Ecto, the prem...
New
shankardevy
Dear Elixir Alchemists I’m happy to share that I’m working on my 2nd series of books (See my first one here) and this time it’s about As...
New
slashdotdash
I’m working on a CQRS/ES and Phoenix book for those interested in building an event driven application using Elixir. The full so...
New

Other popular topics Top

JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
myronmarston
The Elixir Typespec docs show the following syntax for keyword lists in typespecs: # ... | [key: type] # keyword lis...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
josevalim
Hi everyone, One of the features added to Elixir early on to help integration with Erlang code was the idea of overridable function defi...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
Nvim
Elixir appears to be a superior language to Python. I don’t see any advantage of Python over Elixir. Are there any?
New

We're in Beta

About us Mission Statement