I need help with many-to-many relationships for a small music database project. Here are the main entities: albums, artists, tracks, genres, labels, videos [Artists] artist_id, type_id, name [Albums] album_id, title, genre_id, cover_art, label_id, release_date [Artists_Albums] album_id, artist_id [Tracks] track_id, title,album_id, position, length, video_id, lyrics [Artist_Tracks] album_id, track_id, artist_id, credit_id [Credits] credit_id, position [Genres] genre_id, name [Labels] label_id, name [Videos] video_id, title, track_id - an album can have one or more artists - a track can have one or more artists with a join keyword (ex: "Feat", ",", "&") Katy Perry Feat. Kanye West, Rihanna OR Rihanna & Kanye West & Paul McCartney. I'm not sure where to add the join keyword in the table - a track can have one more more videos / a video belongs to a track - a track can have one or more credits (Ex. Producer, Writer) Here's a link to the tables side by side http://prntscr.com/8uutq0 Any help would be appreciated
Hi, You don't need a join keyword. the fact that you have Artists_Albums is enough. This means that you can have the following 2 records Album1, Kanye West Album1, Katy Perry This would mean that album1 has two artists. In order to query this database, you'll just perform something like this: select * from Albums inner join Artists_Albums on Albums.album_id = Artists_Albums.album_id inner join Artists on Artists_Albums.artist_id = Artists.artist_id where Albums.title = 'Album1'; Result= 2 records => Album1, Kanye West + Album1, Katy Perry Hope this helps, Please like my answer if it helps you. Regards,