BIT202 ยท 2078 ยท 5 marks
What is Integrity constraint? What are the three main categories of Integrity constraints.
What is Integrity constraint? What are the three main categories of Integrity constraints. [5]
Database Management SystemChapter 3: Relational Data ModelIntegrity constraints
Quick answer
An Integrity Constraint is a rule or condition imposed on a database to ensure the accuracy, consistency, and validity of data stored in the database. Integrity constraints prevent invalid data from being entered into the database and maintain the correctness of data throughout all operations (insertion, deletion, and update).
Integrity Constraints
Definition
Three Main Categories of Integrity Constraints
1. Domain Integrity Constraints
- These constraints specify that the value of each attribute must be an atomic value from its domain (data type).
- They restrict the type, format, and range of values that can be stored in a column.
- Example: An attribute
Agemust contain only positive integer values; aGenderattribute may only accept'M'or'F'.
2. Entity Integrity Constraints
- This constraint states that the primary key of a relation must be unique and not null.
- Every tuple (row) in a relation must be uniquely identifiable.
- No attribute that is part of the primary key can have a NULL value.
- Example: In a
Studenttable, theStudentID(primary key) must have a unique, non-null value for every student record.
3. Referential Integrity Constraints
- This constraint is defined between two relations and is used to maintain consistency among tuples.
- It states that a foreign key in one relation must either match a primary key value in the referenced relation, or be NULL.
- It ensures that references between tables remain valid.
- Example: In an
Enrollmenttable, theStudentID(foreign key) must correspond to an existingStudentIDin theStudenttable.
Summary Table
| Constraint | Applies To | Key Rule |
|---|---|---|
| Domain Integrity | Attribute values | Values must be within defined domain |
| Entity Integrity | Primary Key | Must be unique and not null |
| Referential Integrity | Foreign Key | Must match a primary key or be null |
Short on time? The 1, 5 and 10 mark versions of this answer, flashcards and practice sets come with a program pass.