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