Beginning SQL Server 2005 Programming P.162
Should there be only one foreign key in a table? The following code gives two Primary Keys: OrderID, PartNo.
Beginning SQL Server 2005 Programming P.162 (ISBN 0-7645-8433-2):
CREATE TABLE OrderDetails
(
OrderID int not null,
PartNo varchar(10) not null,
Description varchar (25) not null,
UnitPrice money not null,
Qty int not null,
Constraint PKOrderDetails
Primary Key (OrderID, PartNo),
Constraint FKOrderContainsDetails
Foreigh Key (OrderID)
References Orders(OrderID)
On Update No Action
On Delete Cascade
)
|