I am building a record collection database. I have a main Release table with Title, Artist, Format, Country, Date, Label, etc. – each of these will be a separate table with a Foreign Key connected back to Release. My question is, do all of the foreign keys in their separate tables connect to one Primary Key (id) in Release or do they each connect to a corresponding Index integer key in Release? And speaking of indexes – is it then necessary to create a separate index on all of the above which will be searched?
Thanks
Given the info you have provided, you would have the following table structure
Releases
ID, Title, ArtistID, FormatID, CountryID, Date, LabelID
Artists
ID (foreign key to ArtistID in Releases table), Name, etc
Formats
ID (foreign key to FormatID in Releases table) , Name, etc
ect etc.
Depends on how you’re planning to search the tables
EDITED:
Exactly. ArtistID will connect to the Artists table where ID is the primary key, but in the Releases table it is a foreign key. Same idea for the rest of the fields, except the Date.
Then you create an index on ArtistFirstName and ArtistLastName fields – these are the fields in the Artists table, and that is what your search is going to search. If you wish to display the artist’s releases, then you have to join Artists and Releases tables on ArtistID (that you would get after search).
It would help if you read up more on the relational database design and normalization.