Home > Database > Mysql Tutorial > body text

What three types of database integrity constraints include

青灯夜游
Release: 2022-01-12 15:01:50
Original
55582 people have browsed it

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.

What three types of database integrity constraints include

The operating environment of this tutorial: windows7 system, mysql8 version, Dell G3 computer.

Three types of integrity constraints in the relational model

1. Entity integrity
2. Referential integrity
3. User-defined integrity

Entity 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.

Referential integrity

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.

What three types of database integrity constraints include

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.

What three types of database integrity constraints include

Referential integrity regulations: foreign code or null value , or is equal to another relationship The main code value in is .

User-defined integrity

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template