Reputation: 41
I am learning SQL Server and am confused as to whether I should put City
, State
and Country
in one table or should I create 3 different tables with foreign keys?
Please suggest which one is best for performance and future modifications etc.
Upvotes: 0
Views: 148
Reputation: 19843
The second one is better, as rule of thumb, always say if I need to rename a 'country' name how many records should be updated, if your answer is 1 then your design is good. (In first design the number of records that should be updated is as much as number of cities in that contry)
Upvotes: 2
Reputation: 28741
Your second database design is hands down better one as it satisfies NORMALIZATION
Upvotes: 1
Reputation: 10098
The second, normalized one, is better, of course.
But you don't need CountryId in City table, if city is dependant on state and only indirectly on country.
Upvotes: 1