Multiple Field Primary Key

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?
 
R

Rick Brandt

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
 
Top