MS SQL Basics Tutorial: Data Integrity Overview

Source: Internet
Author: User

The data in the database is entered from the outside, and the input is invalid or error message for various reasons. Ensure that the data entered conforms to the rules and becomes the data

Library systems, especially multi-user relational database systems, are the primary concerns. Data integrity is therefore proposed. This chapter describes the concept of data integrity and how it is implemented in SQL Server.

Data integrity (Integrity) refers to the accuracy (accuracy) and reliability (reliability) of data. It should prevent the existence of inconsistent semantic data in the database and prevent invalid operations or error messages caused by the input and output of the error message. Data integrity is divided into four categories: Entity integrity (Entity Integrity), Domain integrity

(Domain Integrity), referential integrity (referential Integrity), user-defined integrity (user-definedintegrity).

9.1.1 Entity integrity (Entity Integrity)

Entity integrity stipulates that each row of the table is the only entity in the table. The unique PRIMARYKEY and identity constraints defined in the table are the embodiment of entity integrity.

9.1.2 Field integrity (domain Integrity)

Domain integrity means that a column in a database table must meet a specific data type or constraint. The constraints include the range of values, precision and other provisions. The check, FOREIGN KEY constraint, and default, not NULL definitions in the table are within the domain integrity category.

9.1.3 referential integrity (referential Integrity)

Referential integrity refers to the two-table primary and external keywords data should be consistent. It ensures that the rows of the external keywords for the other tables in the table with the primary key are present, which ensures consistency of data between the tables, preventing data loss or meaningless data from spreading in the database. Referential integrity is based on the relationship between the external keyword and the primary key or between the foreign keyword and the uniqueness keyword. In SQL Server, referential integrity behaves in the following ways:

Prevents the insertion of data rows from a table that contain keywords that do not exist in the primary table;

The prohibition causes the external key value in the primary table orphaned from the corresponding value in the table to change;

Prevents deletion of primary table records that have corresponding records from the table.

9.1.4 user-defined integrity (user-defined Integrity)

According to the different application environment of different relational database system, some special constraint conditions are often needed. User-defined integrity is a constraint on a particular relational database that reflects the semantic requirements that the data involved in a specific application must meet. SQL Server provides a mechanism for defining and verifying such integrity in order to handle them in a unified system approach, rather than using an application to assume this functionality. All other types of integrity support user-defined integrity.

SQL Server provides tools to help users achieve data integrity, most notably rules (rule), defaults (default), Constraints (Constraint), and Triggers (Trigger). The constraints are described in the previous section, and triggers are described in later chapters. This chapter describes the rules and the default values.

See the full set of "MS SQL Basics Tutorials"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.