https://docs.microsoft.com/en-us/sql/relational-databases/tables/create-foreign-key-relationships?view=sql-server-2017

Create a foreign key relationship in Table Designer

Create a foreign key relationship in Table Designer

Using SQL Server Management Studio

  1. In Object Explorer, right-click the table that will be on the foreign-key side of the relationship and click Design.

    The table opens in Table Designer.

  2. From the Table Designer menu, click Relationships.   这里需要先右键选中column,然后才会有menu

  3. In the Foreign-key Relationships dialog box, click Add.

    The relationship appears in the Selected Relationship list with a system-provided name in the format FK_<tablename>_<tablename>, where tablename is the name of the foreign key table.

  4. Click the relationship in the Selected Relationship list.

  5. Click Tables and Columns Specification in the grid to the right and click the ellipses (...) to the right of the property.

  6. In the Tables and Columns dialog box, in the Primary Key drop-down list, choose the table that will be on the primary-key side of the relationship.

  7. In the grid beneath, choose the columns contributing to the table's primary key. In the adjacent grid cell to the left of each column, choose the corresponding foreign-key column of the foreign-key table.

    Table Designer suggests a name for the relationship. To change this name, edit the contents of the Relationship Name text box.

  8. Choose OK to create the relationship.

外键 Foreign keys的更多相关文章

  1. Oracle外键(Foreign Key)使用详细的说明(一)

    Oracle外键(Foreign Key)使用详细的说明(一) 1.目标 演示如何Oracle使用外键数据库 2.什么是外键? 1)在Oracle数据库中,外键是用来实现參照完整性的方法之中的一个.打 ...

  2. 数据库六大约束用法:主键(primary key)、外键(foreign key)、非空(not null)、默认(default)、检查(check)、唯一(unique)

    1. 数据库有六大约束 主键(primary key) 外键(foreign key):被参照的键必须有唯一约束或是主键 非空(not null) 默认(default) 检查(check):orac ...

  3. MYSQL外键(Foreign Key)的使用

    在MySQL 3.23.44版本后,InnoDB引擎类型的表支持了外键约束.外键的使用条件:1.两个表必须是InnoDB表,MyISAM表暂时不支持外键(据说以后的版本有可能支持,但至少目前不支持): ...

  4. MySQL建立外键(Foreign Key)

    如果在最初建立表的时候就建立外键这样一般不会有什么问题,顺便说一下建立外键的时候,需要注意的地方. cascade方式在父表上update/delete记录时,同步update/delete掉子表的匹 ...

  5. 组合外键(FOREIGN KEY)

    一张表,它的外键即是参考另一张表的主键,但这些关联键是组合键,由2列或多列组成. 你可以先看看这篇<多列组合为主键(PRIMARY KEY)>https://www.cnblogs.com ...

  6. 外键(foreign key)的使用及其优缺点

    如果公共关键字在一个关系中是主关键字,那么这个公共关键字被称为另一个关系的外键.由此可见,外键表示了两个关系之间的相关联系.以另一个关系的外键作主关键字的表被称为主表,具有此外键的表被称为主表的从表. ...

  7. 外键约束:foreign key

    *外键 foreign key* 1.概念:如果一个实体的(student)的某个字段,指向(引用)另个实体(class)的主键 (class:class_id),就称为student实体的class ...

  8. PowerDesigner 12小技巧-pd小技巧-pd工具栏不见了-pd修改外键命名规则-pd添加外键

    PowerDesigner 12小技巧-pd小技巧-pd工具栏不见了-pd修改外键命名规则-pd添加外键 1. 附加:工具栏不见了 调色板(Palette)快捷工具栏不见了PowerDesigner ...

  9. mysql 外键 级联

    主表 -- 创建用户信息表 create table userinfo ( userid int primary key not null auto_increment COMMENT '主键', u ...

随机推荐

  1. 大话设计模式C++ 备忘录模式

    备忘录(Memento):在不破坏封装性的前提下,捕获一个对象的内部状态,并在该对象之外保存这个状态.这样以后就可将对象恢复到原先保存的状态. 角色: (1)Originator(发起人):创建盒子, ...

  2. Rpgmakermv(38)MOG_Theatrhythm

    1.============================葡萄牙语=================================================+++ MOG - Theatrh ...

  3. jquer文字闪烁简单实现

    arguments.callee <script type="text/javascript"> (function () { $(".usesend&quo ...

  4. Sitecore系统教程之模板理解

    Sitecore中的所有内容都是一个项目.模板也是如此.Sitecore中的模板是一个项目,它定义了其他项目的结构和行为.Sitecore中的每个项目都是某个模板的实例.模板还可以定义它分解成的部分和 ...

  5. sqoop从hive导入数据到mysql时出现主键冲突

    今天在将一个hive数仓表导出到mysql数据库时出现进度条一直维持在95%一段时间后提示失败的情况,搞了好久才解决.使用的环境是HUE中的Oozie的workflow任何调用sqoop命令,该死的o ...

  6. Hue中hive(hive cli)查询结果中显示列名,不带表名

    hive cli中显示列名 进入hive cli后 set hive.cli.print.header=true; 之后出现列名,但是带了表名前缀,由于网上没找到资料,于是到官网肉眼扫描所有参数,总算 ...

  7. 如何避免Scrum敏捷开发团队反思会形式化,海星法介绍

    如何避免Scrum敏捷开发团队反思会形式化? 迭代压力很大,根本没时间,而且,反思会上大家都在互相推脱责任,会议成了“批斗大会”,所以团队的人都觉得这个会很鸡肋. 很多团队在开反思会时是这么干的:产品 ...

  8. XWIKI部署安装

    http://www.linuxidc.com/Linux/2016-08/134408.htm

  9. python sqlite3 数据库操作

    python sqlite3 数据库操作 SQLite3是python的内置模块,是一款非常小巧的嵌入式开源数据库软件. 1. 导入Python SQLite数据库模块 import sqlite3 ...

  10. ogg 12.3 for sqlserver 2016 CDC模式配置

    本文主要讲述ogg 12.3 通过CDC抽取sqlserver 2016 enterprise的过程,投递配置相对简单,所以不在此阐述. 配置步骤概述 1. 解压ogg 12.3 for sqlser ...