I’ve ran into an issue that I can’t seem to solve.
Say for instance that I have a table with upcoming videogame releases:
GAME
game_ID | title
-----------------------------
1 | Super Mario
2 | Final Fantasy XIII
And then I’ve got a table with releasedates (different dates for ps3 and xbox360 just for the sake of the argument):
RELEASES
game_ID | releasedate | platform
---------------------------------
1 | 20-04-2010 | Wii
2 | 23-03-2010 | PS3
3 | 20-03-2010 | Xbox360
Now, I have put game_ID as the primary key in the table “GAME”. And game_ID is also a foreign key in the table “RELEASES”. What should I have as the primary key in the latter? It seems rather unnecessary to create yet another ID-key in the “RELEASES”-table?
Can I somehow use game_ID and platform together to create the primary-key? If so, how would the SQL look like?
You can create a composite key that consists of
game_idandplatformjust like you create a primary key that consists of only one column: