Data Integrity

It’s all about the accuracy as well as the consistency of the data that’s inside the database !. It also represents the integrity of constraints that business enforces. Depending on the rules they want to apply when they are entered into an application , or their database

Image result for data integrity sql

Let’s see some examples where data integrity could be at risk depending on different situations :

  • A user tries to enter a date outside an acceptable range.
  • A user tries to enter a phone number in the wrong format.
  • A bug in an application attempts to delete the wrong record.
  • While transferring data between two databases, the developer accidentally tries to insert the data into the wrong table.
  • While transferring data between two databases, the network went down.

This is why is so important to always adhere to all integrity rules , to minimize as much as possible , errors in your database.

4 Types of Data Integrity

  • Entity integrity
  • Referential integrity
  • Domain integrity
  • User-defined integrity

Entity Integrity

Entity integrity defines each row to be unique within its table. No two rows can be the same.

Referential Integrity

is concerned with relationships. When two or more tables have a relationship, we have to ensure that the foreign key value matches the primary key value at all times.

Domain Integrity

Domain integrity concerns the validity of entries for a given column. Selecting the appropriate data type for a column is the first step in maintaining domain integrity. 

User-Defined Integrity

User-defined integrity allows the user to apply business rules to the database that aren’t covered by any of the other three data integrity types.

Image result for data integrity sql
Image result for data integrity sql

Leave a comment