The role of SQL Server constraints is to understand [go]

Source: Internet
Author: User

Constraints in SQL Server are used to ensure the integrity of the system. General constraints can be divided into:
PRIMARY KEY constraint
FOREIGN KEY constraints
CHECK constraints
Default Constraints
Unique constraint
Non-null constraint

But in general we need to pay special attention to the first three constraints:
A PRIMARY key constraint, which is a significant relationship to the entity of your system, is used to ensure the integrity of the entity. Requires a table to have only one entity, and in experience it is not possible to have tables in a table. Is it similar to the concept of the first paradigm? Similar to the right, generally do a table of one entity will satisfy the first paradigm
FOREIGN KEY constraints
A FOREIGN key constraint is to ensure the integrity of the reference. In other words, each outside of your system must correspond to an entity (the primary KEY constraint) and not be arbitrarily confused. This is mainly to meet the requirements of the second paradigm

CHECK constraints and default constraints are to ensure the integrity of the data. For example, if you have a table of age field, then be sure to check if he is greater than 0. This is the third paradigm that is mainly said.

We generally do design only need to achieve the second paradigm, blindly meet the three paradigms, in fact, the system will be very large, the maintenance of the later optimization does not have any benefits. The appropriate redundancy data is powerful for the system

The role of SQL Server constraints is to understand [go]

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.