我有同 table 顾客,同 table 卖家;每个顾客都有很多电话号码,就像卖家一样。我决定做新表:电话,包含 IdTelephone、前缀、号码和 IdCustomer 或 IdSeller,我不知道如何识别它,因为 IdCustomer 可能与 IdSeller 相同,如何解决这个问题? Mysql...
最佳答案
您可以这样做,其中 TelephonePerson 包含 customerId 和 TelephoneId 可能为空的列;
Customer Table:
Id
*whatever customer details exist*
Seller Table:
ID
*whatever seller details exist*
TelephonePerson:
SellerId
CustomerId
TelephoneId
Telephone:
ID
Phone Number
或者,为了避免额外的表,您可以这样做,您的电话表上有 linkId 和 PersonTypeId。 PersonTypeId 将指的是卖家或客户,并根据您加入到 linkId 上的相应表中的内容;
Customer Table:
Id
*whatever customer details exist*
Seller Table:
ID
*whatever seller details exist*
Telephone:
ID
Phone Number
LinkId
PersonTypeId
关于mysql - 如何规划具有相同ID的数据库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9734838/