Home > Database > Mysql Tutorial > body text

Data integrity of SQL server database

一个新手
Release: 2017-10-18 10:03:39
Original
1974 people have browsed it

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.


Detailed explanation

The data in the database is input from the outside world, and due to various reasons, invalid input or error messages may occur during data input. Ensuring that the input data complies with regulations has become the primary concern of database systems, especially multi-user relational database systems. Data integrity is therefore brought up. This chapter will describe the concept of data integrity and how to implement it in SQL Server.

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 the input and output of incorrect information. Data integrity is divided into four categories: Entity Integrity, Domain Integrity, Referential Integrity, and User-defined Integrity.

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.

Data integrity: It can ensure the consistency and accuracy of the data stored in the database.

Entity integrity constraints: constraints on a column (primary key (PRIMARY KEY) constraints)

Entity (row) integrity: All rows in the table are required to be unique, such as primary key values.

-------------------------------------------------- -----------

Domain integrity constraints: Constraints on a row (default constraint , check (check) constraint, non not null constraint).

Domain (column) integrity: Specify a set of valid values ​​for the column and decide whether to allow null values. Data integrity can also be enforced by limiting the data type, format, and range of possible values ​​in a column.

-------------------------------------------------- -----------

Referential integrity constraints: Foreign key constraints related to the primary key

Referential integrity: Ensure that the primary key and Relationships with external keywords.

-------------------------------------------------- -----------

User-defined constraints: In addition to implicit constraints, designers of relational databases can also set other specific constraints for the database. Such constraints are called " User-defined constraints”

The above is the detailed content of Data integrity of SQL server database. 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