7 Relational Integrity Constraints
7 Relational Integrity Constraints
It specifies that the value taken by the attribute must be the atomic value from its
domain.
The attribute must follow the data types which include standard data types
integers, real numbers, characters, Booleans, variable length strings, etc.
Example:
S001 Akshay 20
S002 Abhishek 21
S003 Shashank 20
S004 Rahul A
Here, value ‘A’ is not allowed since only integer values can be taken by the age attribute.
Example-SQL statement with check Constraint
Tuple Uniqueness constraint specifies that all the tuples must be necessarily
unique in any relation.
Example-01:
Consider the following Student table-
S001 Akshay 20
S002 Abhishek 21
S003 Shashank 20
S004 Rahul 20
This relation satisfies the tuple uniqueness constraint since here all the tuples are
unique.
Example-02:
Consider the following Student table-
S001 Akshay 20
S001 Akshay 20
S003 Shashank 20
S004 Rahul 20
This relation does not satisfy the tuple uniqueness constraint since here all the tuples are
not unique.
Primary key uniquely identifies each record in a table. It must have unique values
and cannot contain nulls.
Foreign keys are the columns of a table that points to the primary key of another
table. They act as a cross-reference between tables.
Keys are the entity set that is used to identify an entity within its entity set
uniquely.
An entity set can have multiple keys, but out of which one key will be the primary
key. A primary key can contain a unique and null value in the relational table.
Example:
• The entity integrity constraint states that primary key value can't be null.
• This is because the primary key value is used to identify individual rows in
relation and if the primary key has a null value, then we can't identify those rows.
• A table can contain a null value other than the primary key field.
Example:
5. Referential Integrity Constraints
It specifies that all the values taken by the foreign key must either be available in
the relation of the primary key or be null.
Foreign keys are the columns of a table that points to the primary key of
another table. They act as a cross-reference between tables
Example1:
Example2:
Student Department