为什么必须在一个表的列上有一个主键,另一个表的列具有外键引用.
- create table D(Did int)
- create table E(Eid int foreign key references D(Did))
- There are no primary or candidate keys in the referenced table 'D' that match
- the referencing column list in the foreign key 'FK__E__Eid__79C80F94'.
解决方法
简单.如果父表中有两个值相同,那么您如何知道哪一个将子行相关联?
外键的一面必须是明确的
外键的一面必须是明确的
该要求也是“唯一键”,而不仅仅是一个主键,当然是唯一的