Chapter 6
Generators and Relationships

So far, our Ecto tour has been pretty basic. We’ve read and written repository data, but we still haven’t connected any schemas together. Relational databases like PostgreSQL are named that way for a reason. Dealing with related data is the defining characteristic of that whole family of databases, so management of relationships is the feature that makes or breaks any persistence layer. This chapter takes you on a deeper dive into Ecto by exploring how to tie our schemas together in the database.

Throughout this process, we’ll make some design decisions. Our contexts will continue to be the overarching API that our controllers will access. Sometimes those contexts will tie together united concepts. Other times we’ll use contexts to segregate the different concerns of our application.

Along the way, we’ll use code generators to accelerate the process where it’s possible, and you’ll walk through what each of these generators does for us. When you’re through, you’ll know how to take greater advantage of some of the code generators in Phoenix, and you’ll have a better understanding of how to layer together individual Ecto schemas with relationships, and group together related concepts in contexts.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.119.170