Constraints are used to enforce the data integrity.
This ensures the accuracy and reliability of the data in the database. The following categories of the data integrity exist:
• Entity Integrity
ensures that there are no duplicate rows in a table.
It specifying a PRIMARY KEY constraint.Example: the ProductID column of the Products table is a primary key for the table.
• Domain Integrity
enforces valid entries for a given column by restricting the type, the
format, or the range of possible values.
It specifying a CHECK constraints, UNIQUE constraints, and DEFAULT constraints.The following list gives a sampling of domain integrity constraints.
• A product name cannot be NULL.
• A product name must be unique.
• The date of an order must not be in the future.
• The product quantity in an order must be greater than zero.
• Referential integrity
ensures the relationships between tables remain preserved as data is inserted, deleted, and modified.
It specifying a FOREIGN KEY constraint.• User-Defined Integrity
enforces some specific business rules that do not fall into entity, domain, or referential integrity categories.
Microsoft SQL Server supports the following constraints:
• PRIMARY KEY
• UNIQUE
• FOREIGN KEY
• CHECK
• NOT NULL
No comments:
Post a Comment