MySQL中的一对一关系? [英] One-to-One Relationship in MySQL?

查看:79
本文介绍了MySQL中的一对一关系?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的数据库系统中有以下表格,我必须在其中创建发票和付款之间的一对一关系。因为只有一笔付款发生在客户的一张发票上。

并且MySQL不允许一对一的关系,所以我该怎么做才能解决这个问题。

I have the following tables in my Database System for which i have to create one-to-one relationship between Invoice and Payments. As only one payment occurs against one invoice of customer.
And MySQL doesn't allow one-to-one relationship, so what should i do to solve this.

推荐答案

您只需在具有发票ID的付款中添加外键。



有一个类似的例子此博客 [ ^ ]
You can just add a foreign key in Payments that has the Invoice ID.

There is an example of something similar on this blog[^]


这篇关于MySQL中的一对一关系?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆