We help IT Professionals succeed at work.

Primary and foreign keys for SQL Server 2000 tables

printmedia
printmedia asked
on
266 Views
Last Modified: 2012-05-11
Hi all.

I have 3 tables (tblFreightHeader, tblSalesOrder, tblInvoiceNumber)

tblFreightHeader: FreightHeader_ID (PK), Carrier, Weight, FreightAmount
tblSalesOrder: SalesOrder_ID (PK), FreightHeader_ID (FK), SalesOrderNumber, Customer, SalesOrderAmount
tblInvoiceNumber: InvoiceNumber_ID (PK), SalesOrder_ID (FK), InvoiceNumber, InvoiceAmount

They way it works is that there could be multiple sales order for one freightheader record. There could also be multiple invoice number for one sales order (sometimes sales orders are completed in parts i.e. various invoices).

Should I create a foreign key between tblFreightHeader and tblInvoiceNumber?
Comment
Watch Question

Chief Technology Officer
CERTIFIED EXPERT
Most Valuable Expert 2011
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
Thanks for the reply!

So instead of doing the FreightHeader_ID foreign key between blFreightHeader and tblInvoiceNumber I can instead do the FreightHeader_ID foreign key between tblSalesOrder and tblInvoiceNumber?

Commented:
In order to reduce redundancy, you should create foreign keys and normalize the data.  

If you have repeated data in multiple tables, you run the risk of having data that is inconsistent between the tables.
Paul JacksonSoftware Engineer
CERTIFIED EXPERT
Top Expert 2011
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.