Multiple Field Primary Key

  • Thread starter Thread starter northstar
  • Start date Start date
N

northstar

Can someone please give me a couple of examples of a table with a
multiple-field primary key? When would this concept be used?
 
northstar said:
Can someone please give me a couple of examples of a table with a
multiple-field primary key? When would this concept be used?

EX_1:
Two tables:

Orders: PK = OrderNumber
OrderLineItems: PK = OrderNumber; LineNumber

Or where some companies only allow an Item to be listed once on an order....

Orders: PK = OrderNumber
OrderLineItems: PK = OrderNumber; ItemID

EX_2:
Two tables:

Customers: PK = CustomerID
CustomerEmail: PK = CustomerID; EMailAddress

These are more common in cases where the db admin uses natural keys instead
of numeric surrogate keys.

EX_3:
One Table:

Inspections: PK = Warehouse; PartNumber; PONumber;
InspectDateTime
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top