This is (I think) a generic question, but here's a specific example. Suppose that:
Albums
each have 1-nTracks
.- Each
Track
is in exactly oneAlbum
. (Even if "Logging with the Bloggs" appears in both Bloggs' First Album and Bloggs' Greatest Hits, these are 2 entities for my purposes.) - Each
Track
has exactly oneArtist
. Artists
have 1-nTracks
.- Each
Album
has 1Album_Artist
. (Where all theTracks
are by Bloggs, theAlbum_Artist
is Bloggs. Where theTracks
are by different Artists, as in A Collection of Great Logging Songs, theAlbum_Artist
is Various.
I want to be able to answer questions like:
- List all the Bloggs albums
- Find all the Bloggs
Tracks
with 'logging' in the title - List all the
Album_Artists
.
So what's the best table model?
Currently I have an Artists
table with a boolean column for IsAlbumArtist?
Then Tracks
has a foreign key Artist_id and a foreign key Album_id .
and Albums
has a foreign key Artist_id
But would it be preferable to have a separate AlbumArtists
table, or is this a moment to think about table inheritance?
Thanks for any design info and tips!