【发布时间】:2013-07-08 12:41:32
【问题描述】:
在设计 mysql 表时,是否有任何规则来管理外键的放置?
即一些开发人员会这样做。
//Place the "address_id" inside the customer table
//Customer Table
Customer_id, Address_id, Customer_Name
1 1 Jay
//Address Table
Address_id, City
1 London
有些人会这样做。
//Place the "customer_id" inside the address table
//Customer Table
Customer_id, Customer_Name
1 Jay
//Address Table
Address_id, Customer_id, City
1 1 London
哪种方法更好,为什么?这些开发人员在做出与外键放置相关的决定时会考虑什么?
这可能是一个愚蠢的问题,对某些人来说可能很明显。但我真的很难消除这种困惑,希望您能提供帮助。
【问题讨论】:
-
我想你可以在这里看到答案stackoverflow.com/questions/6576901/…
标签: mysql database-design relational-database database-schema