Deepak
Deepak

Reputation: 41

SQL Server database design, which one is better design

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?

enter image description hereenter image description here

Please suggest which one is best for performance and future modifications etc.

Upvotes: 0

Views: 148

Answers (3)

Reza
Reza

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

Mudassir Hasan
Mudassir Hasan

Reputation: 28741

Your second database design is hands down better one as it satisfies NORMALIZATION

Upvotes: 1

dean
dean

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

Related Questions