Home > Common Problem > What three does data integrity refer to?

What three does data integrity refer to?

青灯夜游
Release: 2023-01-13 00:37:22
Original
32801 people have browsed it

Data integrity refers to: 1. Domain integrity, that is, the input validity of a column, whether null values ​​are allowed; 2. Entity integrity, that is, ensuring that all rows in the table are unique; 3. Reference Integrity means ensuring the reference relationship between the primary key (referenced table) and the external key (referring table).

What three does data integrity refer to?

The operating environment of this tutorial: Windows 7 system, Dell G3 computer.

A state in which all data values ​​stored in the database are correct. A database is said to have lost data integrity if it has incorrect data values ​​stored in it.

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 the following 3 categories:

(1) Domain integrity : refers to a column Input validity, whether to allow null values. 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".

(2) Entity integrity: refers to ensuring that all rows in the table are unique. Entity integrity requires that all rows in a table have a unique identifier. This unique identifier may be one column or a combination of several columns, called the primary key. That is, the primary key in the table must have a unique value across all rows. Methods to enforce entity integrity include indexes, UNIQUE constraints, PRIMARY KEY constraints, or IDENTITY attributes. For example: the value of sno (student number) in the student table must be unique. It uniquely identifies the student represented by the corresponding record. Duplicate student numbers are illegal. The student's name cannot be used as the primary key because it is entirely possible for two students to have the same name and surname.

(3) Referential integrity: refers to ensuring the reference relationship between the primary key (referenced table) and the external key (referring table). It involves maintaining the consistency of data in two or more tables. A foreign key value associates a record in the referencing table that contains the foreign key with a record in the referenced table whose primary key matches the foreign key. As records are entered, changed, or deleted, referential integrity maintains defined relationships between tables, 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. For example, the course number of a student's course must be a valid course number. The foreign key cno (course number) in the score table (grade table) will refer to the primary key cno (course number) in the course table (course table) to achieve data integrity.

Domain integrity, entity integrity and referential integrity are implemented on columns, rows and tables respectively. Data integrity can be implemented at any time, but when implementing data integrity on a table with existing data, the system must first check whether the data in the table meets the implemented integrity. Only the data in the table meets the implemented integrity. , data integrity can be implemented successfully.

For more related knowledge, please visit the FAQ column!

The above is the detailed content of What three does data integrity refer to?. 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