2011-03-29 47 views

回答

8

不妨使用複合鍵 - 當你已經擁有複合主鍵的唯一性語義時,不需要添加唯一索引。

+0

+1:我投給了複合材料爲好。 – 2011-03-29 21:45:00

+0

複合鍵向上投。 – Adi 2011-03-29 21:47:36

0

您必須在刪除級聯選項上創建雙向外鍵兩個表。 因爲如果您刪除其中一個類別,那麼它必須刪除ProductCategory上的關係行。

我的意思是,你可以使用這樣的:

alter table ProductsCategory add constraint ForeignKey1 foreign key (ProductId) references Products (ID) ON DELETE CASCADE; 
alter table ProductsCategory add constraint ForeignKey2 foreign key (CategoryId) references Category (ID) ON DELETE CASCADE; 
相關問題