A new version of the “Northwind Elixir Traders” 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-eager 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 Category
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%.
- The book is available as PDF and ePub on Leanpub
- Join the discussion on elixirforum.com
- Leanpub invited me to a short interview about the book