Reputation: 13
I have 2 tables, both relate to eachother as 1:1 -> Country and National_Anthem. Both are in separate tables because I need to store their own metadata.
Now does the FK of Country go in the National_Anthem table OR does the FK of National_Anthem go in the Country table? Since this is 1:1, i guess it can work eitherway?
Upvotes: 1
Views: 78
Reputation: 22187
The basic 1:1 would be:
However, national anthems may change, so:
Upvotes: 1
Reputation: 5880
I agree with @John Zwinck it's subjective, and I would do it the other way around.
Because a National Anthem kind of "belongs" to a country, and if I had a class for each, probably the Country class would have had a NationalAnthem as a property (and so this should be reflected in the DB). But I can't say that's the absolute right answer, and @John has much sense in what he's saying.
Upvotes: 0
Reputation: 249153
This seems subjective, but I would put the link to the country in the anthem table, because I think a national anthem is sort of defined by its country, rather than the other way around. Also a country will have many properties similar to its national anthem (official language for example), and it would be impractical to have all of them reflected in a single table.
Upvotes: 3