一个表有两个外键? [英] Can a table have two foreign keys?
问题描述
我有以下表格(粗体中的主键 斜体)
>
- ID ---名称 ---余额... Account_Name - Account_Type
帐户类别表格
- Account_Type ----余额
客户详情表
- Account_Name --- First_Name ---- Last_Name --- Address
我可以在Customer表中有两个外键,如何在MySQL中实现这两个外键?
更新
我正在为最终项目开发一个基于网络的会计系统。
帐户类别
------余额
资产
负债
权益
费用
收入
资产
- Asset_ID -----资产名称----余额---- 帐户类型
应收帐款:
- Receivable_ID 名称-------地址--------电话----- Asset_ID ---- 帐户类型
应收帐款
- Transaction_ID- ---说明----金额---
余额---- Receivable_ID ---- Asset_ID --- 帐户类型
我使用软件绘制ER(实体关系)图,当我指定关系时,它会自动添加多个外键,如上所示。设计不够健全吗?解决方案是的,Mysql允许这样做。您可以在同一个表上有多个外键。
在此获取更多详细信息 FOREIGN KEY Constraints
I have the following tables (Primary key in bold. Foreign key in Italic)
Customer table
- ID---Name---Balance---Account_Name---Account_Type
Account Category table
- Account_Type----Balance
Customer Detail table
- Account_Name---First_Name----Last_Name---Address
Can I have two foreign keys in the Customer table and how can I implement this in MySQL?
Updated
I am developing a web based accounting system for a final project.
Account Category
Account Type--------------Balance
Assets
Liabilities
Equity
Expenses
Income
Asset
- Asset_ID-----Asset Name----Balance----Account Type
Receivable
- Receivable_ID-----Receivable Name-------Address--------Tel-----Asset_ID----Account Type
Receivable Account
- Transaction_ID----Description----Amount---
Balance----Receivable_ID----Asset_ID---Account Type
I drew the ER(Entity relationship) diagram using a software and when I specify the relationship it automatically added the multiple foreign keys as shown above. Is the design not sound enough?
解决方案 Yes, Mysql allows this . You can multiple foreign keys on the same table.
Get more details here FOREIGN KEY Constraints
这篇关于一个表有两个外键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
- Asset_ID -----资产名称----余额---- 帐户类型
- Receivable_ID 名称-------地址--------电话----- Asset_ID ---- 帐户类型
- Transaction_ID- ---说明----金额---
余额---- Receivable_ID ---- Asset_ID --- 帐户类型 - ID---Name---Balance---Account_Name---Account_Type
- Account_Type----Balance
- Account_Name---First_Name----Last_Name---Address
- Asset_ID-----Asset Name----Balance----Account Type
- Receivable_ID-----Receivable Name-------Address--------Tel-----Asset_ID----Account Type
- Transaction_ID----Description----Amount--- Balance----Receivable_ID----Asset_ID---Account Type
我可以在Customer表中有两个外键,如何在MySQL中实现这两个外键?
更新
我正在为最终项目开发一个基于网络的会计系统。
帐户类别
------余额资产
负债
权益
费用
收入
资产
应收帐款:
应收帐款
我使用软件绘制ER(实体关系)图,当我指定关系时,它会自动添加多个外键,如上所示。设计不够健全吗?
是的,Mysql允许这样做。您可以在同一个表上有多个外键。
在此获取更多详细信息 FOREIGN KEY Constraints
I have the following tables (Primary key in bold. Foreign key in Italic)
Customer table
Account Category table
Customer Detail table
Can I have two foreign keys in the Customer table and how can I implement this in MySQL?
Updated
I am developing a web based accounting system for a final project.
Account Category
Account Type--------------Balance
Assets
Liabilities
Equity
Expenses
Income
Asset
Receivable
Receivable Account
I drew the ER(Entity relationship) diagram using a software and when I specify the relationship it automatically added the multiple foreign keys as shown above. Is the design not sound enough?
Yes, Mysql allows this . You can multiple foreign keys on the same table.
Get more details here FOREIGN KEY Constraints
这篇关于一个表有两个外键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!