I have designed my tables in below manner.
Countries Table:-
PkId --- + Country Name --- + StatusFlag
1 | India | L
2 | China | L
3 | Sri Lanka | L
StateNames Table:-
PkId --- + CountryFkId --- + State Name --- + StatusFlag
1 | 1 | Maharastra | L
2 | 1 | Madhya Pradesh | L
3 | 1 | Utter Pradesh | L
Cities Table:-
PkId --- + StateFkId --- + City Name --- + StatusFlag
1 | 1 | Mumbai | L
2 | 1 | Pune | L
3 | 1 | Nagpur | L
PinCodes Table:-
PkId --- + CityFkId --- + PinCode --- + Area --- + StatusFlag
1 | 1 | 400037 | Antop Hill | L
2 | 2 | 412206 | Ambade | L
3 | 3 | 441108 | Ashta | L
Customers Table:-
PkId --- + CustomerId --- + CustomerName --- + PinCodeFkId--- + StatusFlag
1 | C00001 | John | 1 | L
2 | C00002 | Ram | 2 | L
3 | C00003 | Anwar | 3 | L
Query:-
Select C.CustomerId, C.CustomerName, P.Area, CT.CityName, S.StateName, CNT.CountyName
From dbo.Customers C
Inner Join dbo.PinCodes P On C.PinCodeFkId = P.PkId
Inner Join dbo.Cities CT On P.CityFkId = CT.PkId
Inner Join dbo,StateNames S On CT.StateFkId = S.PkId
Inner Join dbo.Countries CNT On S.CountryFkId = CNT.PkId
But my colleagues told that if I write like this, then huge logical reads will occur. Also they told that these table structures follow too much normalisation. Instead of designing Customers table like above, they have given other suggestion. i.e., Maintaining CountryName, StateName, CityName, PinCode and Area in Customers table itself.
Restructured Customers Table:-
PkId --- + CustomerId --- + CustomerName --- + PinCode --- + Area ------- + CityName --- + StateName --- + CountryName--- + StatusFlag
1 | C00001 | John | 400037 | Antop Hill | Mumbai | Maharastra | India | L
2 | C00002 | Ram | 412206 | Ambade | Pune | Maharastra | India | L
3 | C00003 | Anwar | 441108 | Ashta | Nagpur | Maharastra | India | L
Restructured Query:-
Select CustomerId, CustomerName, Area, CityName, StateName, CountyName
From dbo.Customers
In above query, I didn't put any join conditions with other relevant tables. Which kind of table design best suitable for normalisation and better performance when table has huge number of records?
City
->State
andState
->Country
are pretty obvious;Pincode
->City
would be the one that's not immediately clear. If a pincode and a specific area are tied together one-to-one, and they always belong to a specific city, then it makes sense.