Hello readers both current and prospective,
Lo and behold, I bring you sweet tidings of great progress!
Northwind Elixir Traders is practically completed in terms of content–I am currently working on QA of chapters 15 and 16, but everything else is done. I expect my QA to conclude within the next couple of days.
These two remaining short chapters will cover queries with window functions, as well as some leftovers, such as using Ecto.Enum
, redacting fields with sensitive data, modeling one-to-one associations, and finally checking whether the application also works with Postgres instead of SQLite.
The biggest change since the last update is Chapter 14 on queries. Like a few other chapters before, this too had a big sidequest: dealing with the consequences of the price being originally modeled as a :float
in the Ecto schema of the %Product{}
. After investigating what this causes when we calculate aggregate values of orders’ revenues, we use SQL in a migration to convert the dollar prices to cents and another migration to change the field type to :integer
.
We learn to build increasingly complex queries with both join: ...
and left_join: ...
, and use group_by
and order_by
to build subqueries and dynamic queries. All this allows us to calculate the different entities’ (Customer
, Product
, Category
, Employee
, etc.) share of revenues, also in a cumulative manner. Thus, we even manage to calculate the Gini coefficient of such data pairings!
Besides that, we explore Elixir’s parallel execution capabilities using the Task
module, and the pointlessness of running I/O-bound queries in parallel. We also iteratively refactor the new Insights
module’s function, so that our queries are composable. Throughout the chapter we run numerous queries to derive insights and, not leaving the context of the application behind, we also discuss what could motivate the implementation of such queries we write.
There is now also a Chapter 17 with ideas for where you could take the application with improvements and extensions to the database and the Elixir code.
Thank you to the many readers who gave this book a shot since its infancy in April 2024, and especially to all those who provided feedback. Without your patronage, this book would not have grown to 300+ pages over almost a year!
Once again, if you particularly enjoyed the book and would like to contribute a testimonial for the Leanpub page, email me or connect with me on LinkedIn. My contact details are in the book.
Enjoy Chapter 14, and until very soon again,
Isaak