Wednesday, 13 April 2022

Relational integrity / data integrity constraints

Data integrity constraints refer to the accuracy and correctness of data in the data base. Data integrity provides a mechanism to maintain date consistence for operations like insert, update and delete. The different types of data integrity constraints are 


1.Domain constraint
2.Key constraint
3.Entity Integrity constraint
4.Referential Integrity constraint
5.Null integrity constraint
 

Domain constraint

  1. Domain constraint defines the domain or set of values for an attribute.
  2. It specifies that the value taken by the attribute must be the atomic value from its domain.


Here, value ‘A’ is not allowed since only integer values can be taken by the age attribute.

 

 
Key constraint

Key constraint specifies that in any relation-

  1. All the values of primary key must be unique.
  2. The value of primary key must not be null.


This relation does not satisfy the key constraint as here all the values of primary key are not unique.

Entity Integrity constraint

  1. Entity integrity constraint specifies that no attribute of primary key must contain a null value in any relation.
  2. This is because the presence of null value in the primary key violates the uniqueness property.

Example-

Consider the following Student table-

This relation does not satisfy the entity integrity constraint as here the primary key contains a NULL value.

Referential Integrity constraint

Referential Integrity constraint is a rule that states that either each foreign key value must match a primary key value in another relation or the foreign key value must be null.

Null integrity constraint

Null implies that the data value is not known temporarily. Consider the relation person, the attribute if the relation is name, age and salary. The age of the person can’t be null.

 

NAME

AGE

SALARY

A

30

10,000

B

42

20,000

C

NULL

30,000

 


0 comments:

Post a Comment

Note: only a member of this blog may post a comment.

Find Us On Facebook

Computer Basics

More

C Programming

More

Java Tutorial

More

Data Structures

More

MS Office

More

Database Management

More
Top