SQL Server 2019来自不同表的多列上的外键
因此,我必须创建三个表:
- 第一表是: 在 ,profname nvarchar(50) ,profusername nvarchar(50));
- 第二个是
create table tblstudent(studentId int Indentity(1,1)主键 ,StudentName nvarchar(50) ,NVARCHAR(50));
我想创建第三个表格,该表应该有两个外键,第一个键是从表Tblprof中散发出来的,而Secaond的键则是从表TblStudent中的StudentId。 因此,这是两个奇异表的两个外键,这是可能的吗? 如果是这样,我应该如何创建它?
so i have to create three tables :
- the first one is :
create table TblProf(profId int IDENTITY(1,1) PRIMARY KEY ,profName nvarchar(50) ,profUsername nvarchar(50));
- and the second one is
create table TblStudent(studentId int IDENTITY(1,1) PRIMARY KEY ,studentName nvarchar(50) ,studentUsername nvarchar(50));
and i want to create the third table which should have two foreign keys the first one is profID from the table TblProf and the secaond one is studentId from the table TblStudent.
so it's two foreign keys from two diffrent tables ,is it possible ?
if so how should i create it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这称为桥接
表
This is called a bridge table
you can add more columns, when the bridge has its own propertoes