0

I would like to list all artist's tracks order by track length.

artists     albums        tracks
----------  ------------  ------------
id          id            id
name        artist_id     album_id
            name          name 

or

artists     albums        tracks
----------  ------------  ------------
id          id            id
name        artist_id     album_id
            name          artist_id
                          name

Less data in the first database, but easier queries in the secont database. Which is better?

sticky bit
  • 36,626
  • 12
  • 31
  • 42
David
  • 51
  • 1
  • 6
  • Are you sure that for each album there will be only 1 artist? – forpas Dec 20 '20 at 10:00
  • Move an album to a different artist and you need to update the tracks too in the second one – brombeer Dec 20 '20 at 10:03
  • You need to define all the rules here. For example, can there be tracks that are made by one artist but are on an album from another artist? Can there be more than one artist per track? Can there be more than one artist per album? Can a track belong to multiple albums? – sticky bit Dec 20 '20 at 10:04

1 Answers1

0

The first idea is the best one (in my opinion).

In this case, you avoid the redundancy you have in the second, and so you avoid problem of inconsistency in your database.

jippy13011
  • 11
  • 3