Hi all. I’m new to Elixir and Phoenix, and am not coming from Rails or anything else - I understand the web and SQL moderately well, but am new to MVC’s. My question is about modeling many-to-many relationships in Phoenix ≥ 1.3.
In SQL, I’m used to having a table for one thing (e.g.,
recipes), a table for another (e.g.,
ingredients), and a third that just associates the two (e.g.,
recipe_ingredients). In my actual problem domain, it feels logical to create contexts and schemas for the two primary tables, but I’m wondering how to represent the association table. Do I need a schema for it? Which context might that schema go in? Would each context represent the same table with its own schema?
I realize there are no definite answers and few best practices, but am I roughly on the right track with this, or does the question suggest I’m missing something fundamental about Ecto/Phoenix?
If anyone knows of any really dynamite entry-level (not coming from Rails!) tutorials that really go deeply into how schemas work in Phx ≥ 1.3 (especially if they cover when/why you’d use options like
belongs_to, and what happens if you do/don’t), I’ll be super, super grateful. Thanks for any pointers!