Entity integrity is a basic integrity constraint in relational databases that ensures each row (entity) in a table has a unique and valid identifier. It is enforced through the primary key attribute(s) of the relation.
In simple terms, entity integrity guarantees that no two rows in a table represent the same real‑world entity, and that every row can be clearly distinguished from the others.
What Entity Integrity Requires
Entity integrity imposes two main rules on the primary key of a relation:
Uniqueness:
No two tuples in the relation can have the same primary‑key value.
Every row must have a distinct value (or combination of values) for its primary key.
Non‑null (NOT NULL):
The primary‑key attribute(s) cannot contain NULL values.
Every row must have a valid, real value in the key column(s).
Together, these rules ensure that the primary key truly acts as a unique identifier for each row.
Example of Entity Integrity
Consider a relation EMPLOYEE(emp_id, name, salary, dept) where emp_id is the primary key.
Valid table (satisfies entity integrity):
Here:
All
emp_idvalues are unique and non‑null, so entity integrity holds.
Invalid cases that violate entity integrity:
Two rows with
emp_id = 101→ violates uniqueness.A row with
emp_id = NULL→ violates non‑null rule.
Such rows would be rejected by the DBMS when entity integrity is enforced.
Why Entity Integrity Matters?
It ensures that each row can be uniquely identified, which is essential for updates, deletes, and joins.
It prevents duplicate entities and ambiguous references in the database.
It forms the foundation for other constraints like foreign keys and referential integrity.