Skip to main content

What is data integrity?

Data integrity is a database property that guarantees correctness, consistency, and reliability of information while it's being stored and processed.

The main types of integrity

  1. Entity Integrity
  • Every record in a table must have a unique identifier (a primary key).
  • This ensures there are no duplicate or "empty" records.
  1. Referential Integrity
  • A foreign key's values must match existing values of the primary key in the other table.
  • It prevents "orphaned references", for example, an employee can't reference a department that doesn't exist.
  1. Domain Integrity
  • A field's values must match the allowed data type and constraints (e.g. number, text, date).
  • For example, the Age field can't hold the text "thirty".
  1. User-defined Integrity
  • Additional rules set by business logic, for example: a salary can't be negative.

Put simply, data integrity guarantees that the database holds truthful, logical, consistent information, and that no data operation breaks these rules.

Short Answer

Interview ready
Premium

A concise answer to help you respond confidently on this topic during an interview.