[英]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; 我正在设计一个具有以下属性相关性的数据库:方法1:A <-B <-C <-D方法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 方法1的样本表
Country_info ------------- , state info, city_info, village_info Country_info -------------,州信息,city_info,village_info
id | id | country_id |
country_id | name
名称
TABLE PAIRS 餐桌对
id | id | state_id |
state_id | country_id
country_id
id | id | division_id |
division_id | state_id
state_id
id | id | village_id |
village_id | division_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. 使用第二种方法,村庄表将具有divide_id,state_id和country_id。
Thanks! 谢谢!
如果村庄是经常使用的“主要”对象(并且也经常使用它与其他表的关系),那么通过使用第二种方法,您将减少代码行数并提高性能(例如,按国家对村庄进行过滤) 。
KISS. 吻。
Table 1: A business/person/etc has an address and a City. 表1:商家/人员/等具有地址和城市。
Table 2: The City also includes the Viliage, State, Province, Country_code, Postal_code, whatever. 表2:城市也包括Viliage,州,省,国家/地区代码,邮政编码。
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! 如果您有六个表,请想象获得地址的所有部分所需的
JOINs
数量!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.