Relationships

Our objective here is to implement the relationship between the Media and Owner schemas. In the beginning, a media file will only have a single owner: the user who uploaded the media into the system. This user can then share it with other users. As such, a media file may be owned by more than one user, and it will certainly be owned by at least one.

On the opposite side of this relationship, we have the media owners. A recently-created user won't have any media files, but eventually it will have dozens of files:

In database parlance, we have a classical many-to-many relation. As such, we need an additional association table, ...

Get Mastering Elixir now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.