Home > Database > Mysql Tutorial > body text

What does data integrity mean?

青灯夜游
Release: 2021-06-15 09:04:05
Original
21677 people have browsed it

Data integrity refers to the accuracy and reliability of data. It refers to ensuring that the information or data is not tampered with without authorization or can be quickly discovered after tampering during the process of transmitting and storing information or data. . Data integrity can be divided into four categories: entity integrity, domain integrity, referential integrity, and user-defined integrity.

What does data integrity mean?

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

Data integrity is one of the three basic points of information security. It refers to ensuring that the information or data is not tampered with without authorization or is tampered with during the process of transmitting and storing information or data. can be discovered quickly.

Data integrity (Data Integrity) refers to the accuracy (Accuracy) and reliability (Reliability) of data. It is proposed to prevent the existence of data that does not comply with semantic regulations in the database and to prevent invalid operations or error messages caused by input and output of incorrect information.

Data integrity is divided into four categories: entity integrity (Entity Integrity), domain integrity (Domain Integrity), referential integrity (Referential Integrity), and user-defined integrity (User-definedIntegrity).

1. Entity integrity

Entity integrity is one of the three rules of database integrity in the relational model. The rule of entity integrity requires that each data table must have a primary key, and the attributes of all fields used as primary keys must be unique and non-null.

2. Domain integrity

Domain integrity: refers to the input validity of a column and whether null values ​​are allowed. Methods to enforce domain integrity include: restricting the type (by setting the data type of the column), the format (through CHECK constraints and rules), or the range of possible values ​​(through FOREIGN KEY constraints, CHECK constraints, DEFAULT definitions, NOT NULL definitions and rules ). For example: the student's test score must be between 0 and 100, and the gender can only be "male" or "female".

3. Referential integrity

Referential integrity: refers to ensuring the reference between the primary keyword (referenced table) and the external keyword (referencing table) relation. It involves maintaining the consistency of data in two or more tables.

The foreign key value associates the record containing the foreign key in the referencing table with the record in the referenced table whose primary key matches the foreign key.

Referential integrity maintains defined relationships between tables when records are entered, changed, or deleted, ensuring that key values ​​are consistent across all tables. Such consistency requirements ensure that non-existent values ​​are not referenced and that if a key value changes, all references to that key value are changed consistently throughout the database.

Referential integrity is based on the relationship between foreign keys and primary keys.

4. User-defined integrity

User-defined integrity is a constraint for a specific relational database, which reflects the constraints involved in a specific application. The semantic requirements that the data must meet. It mainly includes non-null constraints, unique constraints, check constraints, primary key constraints, and foreign key constraints.

The database uses a variety of methods to ensure data integrity, including foreign keys, constraints, rules, and triggers. The system handles the relationship between these four very well, and uses different methods according to different specific situations, and they are used interchangeably to complement each other's shortcomings.

Integrity constraints

Integrity constraints mainly include entity integrity constraints, referential integrity constraints, functional dependency constraints, and statistical constraints. kind.

1) Entity integrity: stipulates that each row of the table is a unique entity in the table.

2) Domain integrity: It means that the columns in the table must meet certain data type constraints, which include value range, precision and other regulations.

3) Referential integrity: means that the data of the primary key and foreign key of the two tables should be consistent, ensuring the consistency of data between tables and preventing data loss or meaningless data. spread in the database.

4) User-defined integrity: Different relational database systems often require some special constraints based on their application environments. User-defined integrity is a constraint for a specific relational database, which reflects the semantic requirements that a specific application must meet.

Types of integrity constraints

can be divided into three types: table-related constraints, domain constraints, assertions ( Assertion)

1) Table-related constraints: It is a constraint defined in the table. The constraint can be defined when the column is defined, which is called a column constraint, or it can be defined when the table is defined, which is called a table constraint.

2) Domain constraint: A constraint defined in the domain definition, which is related to any column defined in a specific domain.

3) Assertion: A constraint defined when the assertion is defined, which can be associated with one or more tables.

(Recommended tutorial: mysql video tutorial)

The above is the detailed content of What does data integrity mean?. 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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!