The second part of Chapter 11 of the “Northwind Elixir Traders” book is now available. This release completes Chapter 11, which proved to be the longest so far, despite initial appearances that it would be rather straightforward.
Chapter 11 has seen a meticulous approach to table modeling within the Northwind Elixir Traders (NET) database. We revisit our methodical SIPOC’ed process of table creation four times, adapting it for each table’s unique needs beyond the OrderDetails table, which was reserved for future query capabilities via Ecto.Query
.
The focus in this chapter (and where most of the content is spent) shifted to data integrity and internationalization for Shippers and Suppliers tables with phone number fields. By creating a custom changeset validation function using helper functions, we automate conversions of NANP-formatted numbers into international formats across all pertinent tables, including the development of associated modules that model Country records, and the PhoneNumbers
module that includes various helper functions for phone number processing. Another fruit of this labor is a country validation function that uses publicly available ISO 3166-1 data on CLDR display names (“Greece”), Alpha-3 codes (“GRE”), and dial codes ("+30").
The various custom validation functions have now been refactored in a separate Validations
module, to that they can be used across various modules’ changeset/2
functions.
Finally, the chapter also involves rudimentary exploration of the original Northwind Traders dataset as an investigation and source of discussion for potential improvements to the NET database schema to better match the practical needs of a real-life B2B business.
We are thus now at the cusp of modeling the last table of NT, OrderDetails, and thus leaving the original database behind–for good, and eventually, for better!
The next chapter will do exactly that, before we proceed to Ecto queries and other Ecto topics, such as embedded schemas, Enums, and custom field types. These latter elements will be part of the closing chapters of the book that will take NET beyond the pedagogical status of NT and well into something that could serve as a starting blueprint for a real-life B2B business (which is informed by my professional experience as the Managing Director of TECTRA Ltd , where my business programming journey began).
- 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