I've just thinking about this multi-columns/composite-key using QxOrm to build this table below:
- Code: Select all
Create table CustomerProducts
(
CustomerID int references Customers(CustomerID) not null,
ProductID int references Products(ProductID) not null,
OrderLimit int not null,
Primary key (CustomerID, ProductID)
)
The CustomerID and ProductID, both are as the Reference and also the Primary Key.
How you define those CustomerProducts class table related to Customer and Product tables?
Anyway I still can do this statement using single Primary Key for that particular case:
- Code: Select all
Create table CustomerProducts
(
Customer_ProductID int identity primary key,
CustomerID int references Customers(CustomerID) not null,
ProductID int references Products(ProductID) not null,
OrderLimit int not null
)
But I prepared to choose the first statement to avoid duplicated data like this:
- Code: Select all
CustomerProductID CustomerID ProductID OrderLimit
1 1 100 25
2 1 100 30
best regards,
hdy