I am new to SQL and I have a question regarding table relationships. 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!
Concern: Am I assigning the foreign/primary keys correctly in this scenario?
The PK/FK assignment seems to be ok. Although I would suggest the following:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.