문제

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.

도움이 되었습니까?

해결책

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

다른 팁

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top