我需要构建一个联结表,以获取两个父表之间的多对多关系。设计已经确定。当FK默认情况下会重复时,如何将我的联结表限制为子表?
create table FactInternetSalesReason
( SalesOrderNumber int,
SalesOrderLineNumber int,
SalesReasonKey int,
CONSTRAINT FK_SalesOrder FOREIGN KEY (SalesOrderNumber, SalesOrderLineNumber) REFERENCES FactInternetSales (SalesOrderNumber, SalesOrderLineNumber),
CONSTRAINT FK_SalesReason FOREIGN KEY (SalesReasonKey) REFERENCES DimSalesReason (SalesReasonKey)
);
答案 0 :(得分:0)
外键可以包含重复项(试一试)。主键不能。