Announcing the Northwind Elixir Traders book on Ecto

Announcing the Northwind Elixir Traders book on Ecto

20 February, 2024 3 min read
software, programming, Elixir, learning, Ecto, databases, book

Announcing my new side-project and first non-fiction, technical #book: a practical tutorial of working with databases using Elixir and its Ecto database layer.

Those of us who were around in the 90s and learned some things about databases by playing with the earliest versions of Microsoft Access might remember the “Northwind Traders” database.

This simple database, complete with mock data across 8 interconnected tables, models the commercial operations of a business and serves as grounds for experimenting with table schemas, primary and foreign keys, one-to-many relations, and even a many-to-many relation.

It’s a simple, didactically well understood example that I am using as the basis of taking the “Northwind Traders” database from its initial state to an implementation with Elixir and Ecto as the database of “Northwind Elixir Traders”, complete with the original data and many different data analyses using Ecto queries.

The difference between this book and many other books, and compared to the few other books on Ecto, is that I’m not pursuing the “happy path”, which is why the book ends up being less dry and formulaic, and more an exploration of Ecto that should make the content more memorable than showing exactly what to do to get the results you want, but leaves you SOL when things don’t work as you intuited.

In particular, instead of going with Postgres, the default option for Ecto, I choose SQLite3, making a conscious trade-off in favor of simplicity against feature-richness. This means that not everything ends up working as you expect them to, because e.g. SQLite3 doesn’t support ALTER COLUMN (thus rendering some Ecto.Migration functions useless), or doesn’t respect the column’s :size option, or stores dates as TEXT, etc.

This means that the book teaches you to

  1. make a conscious tradeoff in favor of simplicity instead of feature-completeness in terms of the database technology choice,
  2. define things as if your database supported everything Postgres supports, so you still know what is possible with Ecto,
  3. discover what doesn’t actually do anything or as much as you expected based on Ecto’s docs when you use SQLite3,
  4. understand that it doesn’t really matter in terms of implementation (and learning!), and that you might have been too “smart” about it,
  5. go one abstraction layer higher and work on #Elixir code with Changesets and the Repo instead of fussing over database technologies as if you’re part of the Postgres core team and/or building the next Github (famously running on MySQL).

Ultimately, the book teaches you to value reading documentation to inform yourself and figure things out without fretting, to fearlessly plow ahead even when things don’t work according to the “happy path” in the documentation, and to thus gain a deep understanding of Ecto.

The book should be ready in around one or two months, but I will pre-launch it on Leanpub while it’s still work-in-progress. Feedback from friends so far is positive.