我有三个表如下 -
但是当我添加外键引用时,关系是(数据库图中的一条直线)没有显示。
以下是我写的参考。
ALTER TABLE [dbo].EmployeeDesignation
ADD CONSTRAINT FK_EmployeeDesignation_Employee FOREIGN KEY (EmployeeId)
REFERENCES Employee (EmployeeId)
ON DELETE CASCADE
ON UPDATE CASCADE
;
ALTER TABLE [dbo].[EmployeeDesignation]
ADD CONSTRAINT FK_EmployeeDesignation_Designation FOREIGN KEY (DesignationId)
REFERENCES Designation (DesignationId)
ON DELETE CASCADE
ON UPDATE CASCADE
;
此外,当我添加另外两个表 ( Department and EmployeeDepartment
) 时,我可以在图中看到关系
参考代码如下——
ALTER TABLE [dbo].EmployeeDepartment
ADD CONSTRAINT FK_EmployeeDepartment_Department FOREIGN KEY (DepartmentId)
REFERENCES Department (DepartmentId)
ON DELETE CASCADE
ON UPDATE CASCADE
;
ALTER TABLE [dbo].EmployeeDepartment
ADD CONSTRAINT FK_EmployeeDepartment_Employee FOREIGN KEY (EmployeeId)
REFERENCES Employee (EmployeeId)
ON DELETE CASCADE
ON UPDATE CASCADE
;
后一个显示关系线而前一个没有显示的原因可能是什么?我错过了什么吗?
谢谢 !