[英]SQL - Table Relationships, Primarily (PK/FK)
I am new to SQL and I have a question regarding table relationships. 我是SQL的新手,我对表关系有疑问。 Currently, I have the following tables in my database: 当前,我的数据库中有以下表格:
Person: 人:
Person_ID (PK)
Name
Company_ID(FK)
Phone
Email
Company: 公司:
Company_ID (PK)
Name
Address
City
State
Invoice_ID (FK)
Invoice: 发票:
Invoice_ID (PK)
Summary_ID (FK)
Detailed_ID (FK)
Summary_Section: 摘要部分:
Summary_ID (PK)
InvoiceNumber
Date
DueDate
Detailed_Section: 详细部分:
Detailed_ID (PK)
Person_ID (FK)
Amount
Info
Basically, each company has multiple people and receives one invoice. 基本上,每个公司都有多人,并且会收到一张发票。
Each invoice is broken into two sections: 每张发票分为两部分:
The summary section shows the company name, company address, invoice number, invoice date, & due date. 摘要部分显示公司名称,公司地址,发票编号,发票日期和到期日。
The detailed section shows the person's name, amount, & additional info. 详细部分显示此人的姓名,金额和其他信息。
Am I going about this all wrong? 我要解决所有这些错误吗? What would be the best way to go about this? 最好的方法是什么? Thank you! 谢谢!
EDIT: 编辑:
Concern: Am I assigning the foreign/primary keys correctly in this scenario? 关注:在这种情况下,我是否正确分配了外键/主键?
The PK/FK assignment seems to be ok. PK / FK分配似乎还可以。 Although I would suggest the following: 尽管我建议以下内容:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.