SQL Server Database Learning notes-FOREIGN key

Source: Internet
Author: User

About the primary key. It is very well understood that the primary function of the primary key is to identify a data is unique, that is, to ensure the entity integrity of the data. Prevent data duplication. But foreign key words have a lot of questions, then what is the foreign key?

1. Definition of foreign keys:

A foreign key (FK) is one or more columns used to establish and strengthen the connection between two table data. You can create a connection between two tables by adding values from one or more columns that hold the primary key values in the table to another table. This column becomes the foreign key of the second table. It represents a relationship between two tables.

2. Why use foreign keys?

To ensure referential integrity of the data. Supplement: Referential integrity requirements are not allowed to reference entities that do not exist in the relationship. and entity integrity are the integrity constraints that the relational model must satisfy in order to ensure the consistency of the data.

SQL Server Database Learning notes-FOREIGN key

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.