The rationale behind the `belongs_to` name

Many words have been spent discussing Phoenix Contexts. I’d suggest starting here How would you explain Phoenix Contexts to a newbie?

It’s been a long time since I read DDD, but if you squint you can correlate Phoenix contexts with a less strict type of bounded context.

The basic idea is that Ecto Repos do not have to map 1:1 with physical databases. You can set up an Ecto Repo per aggregate/context if you want. I have done this once with the idea that we might want to shift the database tables backing a particular aggregate to another physical database in the future. With this Repo separation, it would only involve Repo config change but no real code change. It offers a finer grain to the Repository pattern than most users of Ecto consider.

1 Like