Archive

Archive for November 23, 2010

DB Basics – Integrity Constraints in a Database (SQL Server)

November 23, 2010 7 comments

 
Integrity constraints are used to ensure accuracy and consistency of data in a relational database. Data integrity allows to define certain data quality requirements that the data in the database needs to meet. If a user tries to insert data that doesn’t meet these requirements, the RDBMS will not allow so.
 

A Constraint is a property assigned to a column or the set of columns in a table that prevents certain types of inconsistent data values from being placed in the column(s). Constraints are used to enforce the data integrity. This ensures the accuracy and reliability of the data in the database.
 

CONSTRAINT = The threat or use of force to prevent, restrict, or dictate the action or thought of others.
 

–> There are 7 types of Constraints and they are grouped in to 4 types:

A. ENTITY INTEGRITY 1. Primary Key blog post video
2. Unique Key video
B. REFERENTIAL INTEGRITY 3. Foreign Key blog post video
C. DOMAIN INTEGRITY 4. NOT NULL blog post video
5. DEFAULT
6. CHECK
D. USER DEFINED INTEGRITY 7. RULES blog post video

 

–> Check the video with discussion on all these Constraints:

Integrity Constraints