简体   繁体   中英

Database Dependencies - Database Design

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;

  • With the first approach, attribute D is dependent on attribute C, C on B and B on A.
  • With second approach, attribute D can be gotten directly from A.

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

country_state

id | state_id | country_id

state_division

id | division_id | state_id

village_division

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!

如果村庄是经常使用的“主要”对象(并且也经常使用它与其他表的关系),那么通过使用第二种方法,您将减少代码行数并提高性能(例如,按国家对村庄进行过滤) 。

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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM