为两个表中的一列定义外键 [英] Define a Foreign Key for one column in two Tables

查看:99
本文介绍了为两个表中的一列定义外键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在两个表中为一列定义一个外键。



我在VWD 2010工作。



我尝试了SELECT * FROM Employees INNER JOIN Departments ON(Employees.DepartmentID = Departments.ID);



这有用但我添加时 ADO.net实体数据模型它没有显示两个表之间的外键桥。



如何获得该桥?

解决方案

您需要对外键重点进行一些研究[ ^ ]

这样的东西可能有用

  ALTER   TABLE 员工
ADD CONSTRAINT FK_Department FOREIGN < span class =code-keyword> KEY (DepartmentID)
REFERENCES 部门(ID);


I want to define a Foreign Key for one column in two Tables.

I am working in VWD 2010.

I tried "SELECT * FROM Employees INNER JOIN Departments ON (Employees.DepartmentID = Departments.ID);

That worked but when I add "ADO.net Entity Data Model" it did not show the Foreign Key Bridge between the two tables.

How do I get that bridge?

解决方案

You need to do some research on Foreign Key Contraints[^]
Something like this might work

ALTER TABLE Employees
ADD CONSTRAINT FK_Department FOREIGN KEY (DepartmentID)
    REFERENCES Departments (ID) ;


这篇关于为两个表中的一列定义外键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆