如何在mysql中设置一对一的关系基数?
我需要有关我需要在 mysql 数据库中执行的一对一关系的帮助。 我尝试在 stackoverflow 问题中找到答案,但找不到。 我有一个表联系人和一个表地址,表联系人有 4 个地址 id,因此该 id 必须是地址表的 4 个外键,并且在地址表中,我需要有一个联系人外键。我这样说对吗?这会给我一个 (联系人)1:*(地址) 关系?
我怎样才能建立这种关系?
i need help with this one to one relation that i need to do in my mysql database.
I try to find the answer in the stackoverflow questions but i cant find it.
I have a table contact and a table address, the table contact has 4 address id's so this id's must be 4 foreign keys to the address table and in the address table, i need to have a contact foreign key. I'ts this correct? This would give me a (contact)1:*(address) relation?
How can i make this relation?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这里有一个多对多的关系。您需要通过引入新的桥接表
ContactAddressXref
来解决此问题,该表包含联系人表和地址表的外键。You have a many-to-many relationship here. You need to resolve this by introducing a new bridge table,
ContactAddressXref
, that contains foreign keys to both the Contact and Address tables.