Home >Database >Mysql Tutorial >What three types of database integrity constraints include
There are three integrity constraints of the database: 1. Entity integrity, which is a constraint on the uniqueness of the records in the relationship, that is, the primary key; 2. Referential integrity, which is a restriction on the data tables that establish relationships in the relational database. Constraints on data reference references, that is, constraints on foreign keys; 3. User-defined integrity, constraints on a specific relational database.
The operating environment of this tutorial: windows7 system, mysql8 version, Dell G3 computer.
1. Entity integrity
2. Referential integrity
3. User-defined integrity
If attribute A is the main attribute of basic relationship R, attribute A cannot take a null value.
Entity integrity stipulates that all primary attributes of the basic relationship, cannot take null values.
Foreign code: In relationship R, there is one or a group of attributes that are not the main code, and this attribute corresponds to the primary key in another relationship S. Then the attribute is the foreign key of R.
This attribute or attribute group can be associated with the primary key of the current relationship.
For example, the prerequisite course number and course number in the picture below are related.
Referential integrity regulations: foreign code or null value , or is equal to another relationship The main code value in is .
1.unique(only)
2.check(meets a certain condition)
3.not null(not null) Is a null value)
User-defined integrity is a constraint for a specific relational database. Reflects the semantic requirements that the data involved in a specific application must meet.
There are no unified rules for user-defined integrity. It is created by database designers based on the semantic requirements of the data in specific applications.
Related free learning recommendations: mysql video tutorial
The above is the detailed content of What three types of database integrity constraints include. For more information, please follow other related articles on the PHP Chinese website!