Create another table called Song_Composer
, containing two columns: Song_ID
and composer_ID
. Then you can associate as many composers as you like with each song by adding rows with the same song ID
How do I design a database with one-to-one or one-to-many relationships for a column?
-
01-07-2022 - |
Question
I am designing a database to store metadata about music.
For instance, I would store the following data:
Song : A Year Without Rain Album : A Year Without Rain Artist : Selena Gomez & the Scene Composers : Lindy Robbins, Toby Gad
...into these 5 tables:
Songs : song_ID, songTitle, album_ID, artist_ID, composer_IDs Albums : album_ID, albumTitle Artists : artist_ID, artistName, performer_IDs Performers : performer_ID, performerName Composers : composer_ID, composerName
The problem is, for a given song (song_ID), there could either be one or more more than composer (composer_IDs) associated with it. The same goes for the number of members (performer_IDs) in a band (artist_ID).
I don't want to use arrays or comma-separated values to store multiple values in these columns. How do I fix this problem?
I already read this answer, but I couldn't figure out how to implement that with this design. Any help would be appreciated.
Solution
OTHER TIPS
Change the table structure and also add two tables SongsComposers
& ArtistsPerformers
Songs : song_ID, songTitle, album_ID, artist_ID
Composers : composer_ID, composerName
SongsComposers :song_ID,composer_ID
Artists : artist_ID, artistName
Performers : performer_ID, performerName
ArtistsPerformers :artist_ID,performer_ID