Relational Constraints

There are three types of constraints on relational database:
  • Domain Constraints
  • Primary Key Constraints
  • Integrity Constraints

Domain Constraints:
It specifies that each attribute in a relation must contain an atomic value only from the corresponding domains. Domain constraint specifies the condition that we want to put on each instance of the relation. So the values that appear in each column must be drawn from the domain associated with that column.

Key Constraints:
This constraints states that the key attribute value in each tuple must be unique, i.e., no two tuples contain the same value for the key attribute. This is because the value of the primary key is used to identify the tuples in the relation.

Integrity Constraints:
There are two types of integrity constraints:
  • Entity Integrity Constraint
  • Referential Integrity Constraint


Entity Integrity Constraint:
It states that no primary key value can be null. This is because the primary key is used to identify individual tuple in the relation. So we will not be able to identify the records uniquely containing null values for the primary key attributes.

Referential Integrity Constraint:
It states that the tuple in one relation that refers to another relation must refer to an existing tuple in that relation. This constraint is specified on two relations, not necessarily distinct. Database Management System A referential constraint is the rule that the not null values of a foreign key are valid only if they have a match with the primary key of the associated parent table.