Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors

Explain the following constraints : i. Entity integrity constraint. ii. Referential integrity constraint. iii. Domain constraint.

Entity Integrity Constraint:

  • Rule: No primary key attribute can have a null value.
  • Example: In the table where SID is the primary key, every SID must have a value. So, having a null value for SID is not allowed.
SIDNameClass (semester)Age
8001Ankit1st19
8002Srishti1st18
8003Somvir4th22
8004Sourabh6thA

Referential Integrity Constraint:

  • Rule: If a foreign key in one table refers to the primary key in another table, every foreign key value must either be null or exist in the referenced table.
  • Example: In the second table, the DNO (Department Number) is a foreign key that refers to the DNO in the third table. Every DNO in the second table must be either null or match a DNO in the third table.
ENONAMEAgeDNO
1Ankit1910
2Srishti1811
4Sourabh2214
DNOD.Location
10Rohtak
11Bhiwani
12Hansi

Domain Constraints:

  • Rule: Specifies the allowed set of values for an attribute based on its data type.
  • Example: If the Age attribute is defined as an integer, then every value in the Age column must be a valid integer.
SIDNameClass (semester)Age
8001Ankit1st19
8002Srishti1st18
8003Somvir4th22
8004Sourabh6thA

These constraints help maintain the accuracy, consistency, and reliability of data in a database.

Leave a Comment