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:
- Summary
- Detailed
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?