我不是 DBA,我不知道什么是最好的解决方案。我有两个表,
Custumers Table
CustomerId (primary key, identity)
...
和
Suppliers Table
SupplierId (primary key, identity)
...
我想存储多个电话号码和多个电子邮件。我想创建另外两个表,电子邮件和电话,并使用它们与我的客户和供应商联系,比如
Telephones Table
Id
UserId (reference to SuppliersId or CustomerId)
Value
...
但如果我将身份用作客户和供应商的 key ,我肯定会遇到问题。我正在考虑做类似的事情
Telephones Table
Id
SuppliersId
CustumersId
Value
...
但我不知道是不是一个好的设计。有什么建议吗? 谢谢
最佳答案
一个想法:
Entity (ID (PK), {common fields})
Customer (ID (PK), EntityID (FK), {other fields})
Supplier (ID (PK), EntityID (FK), {other fields})
Telephone (ID (PK), EntityID (FK), Value)
这还具有减少客户和供应商之间重复工作的额外优势。
关于数据库设计 : best approach,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14455039/