Reputation: 50
I'm designing a database with the following attribute dependencies: Approach 1: A <- B <- C <-D Approach 2: A <- B, {A,B} < C, {A,B,C} <- D;
Please I need your help on which approach is better. Thanks
EDIT
Sample tables for approach 1
Country_info ------------- , state info, city_info, village_info
id | country_id | name
TABLE PAIRS
id | state_id | country_id
id | division_id | state_id
id | village_id | division_id
Now, I have the id of a village and I want to know the name of the country in which it belongs. I will have to look for the division, state before arriving at the country.
With the second approach, the village table will have the division_id, state_id and the country_id.
Thanks!
Upvotes: 0
Views: 52
Reputation: 142218
KISS.
Table 1: A business/person/etc has an address and a City.
Table 2: The City also includes the Viliage, State, Province, Country_code, Postal_code, whatever.
Normalizing each layer is overkill.
If you have half a dozen tables, imagine the number of JOINs
needed to get all the parts of the address!
Upvotes: 1
Reputation: 92347
If village is "main" obiect which will be used very often (and it's relations to other tables will be also often used) then by using second approach you will reduce number of code lines and increase performance (eg. in filtering villages by country).
Upvotes: 1