Changing Data and Table Structure Together
Our new compositions table is working better now that we’ve added some indexes, but as we start adding data, we discover another problem. Our current structure only allows us to associate one composer with each record, and some songs have more than one composer. As we think about it further, we realize that many songs have separate composers and lyricists, and we might want to capture that info as well.
This sounds like a job for a many-to-many relationship between compositions and artists: a composition can have many artists, and an artist can contribute to many songs. As we discussed in Chapter 3, Connecting Your Tables to Elixir Structs with Schemas we’ll need a new join table between compositions ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access