Hi,
First of all, you can have
only one primary key. You can have multiple columns in your primary key. Such key is called
a compound or composite primary key.
According to your example:
create table Item(
Item_UID int,
Item_ID varchar(15),
Item_Description varchar(300)
primary key (Item_UID),
constraint fk_PerItem foreign key (Item_ID) references ItemsInOrder(Order_Num, Item_ID));
This is important: You need to have a
Order_Num column in your
Item table (I haven't added it into this example). Otherwise, you just can't create a foreign key relationship!
---------------------------------------------------------------------------------------
My thoughts about your data model:
1. Why do you need a composite primary key in
ItemsInOrder table? I would say that you could add
ItemsInOrder_ID column and make it as simple primary key.
2. Relationship between
Item and
ItemsInOrder tables should be one-to-many.
3. Relationship between
Orders and
ItemsInOrder tables should be one-to-many.