A-Z Popular Blog Databases Search »
Technology
 Advertisements
Related Guides

What is Referential Integrity?

 , updated on December 22, 2016
Referential integrity is the validity of relations in a database.

Technical Details

Referential integrity is the validity of foreign keys in a relational database. If you create a row with a foreign key, that foreign key needs to exist in the parent table as a primary key. Likewise, if you delete a row that is referred to by the foreign keys of child rows, those child rows need to be updated.

Enforcement

It is common for databases to enforce referential integrity automatically. This behavior can be defined for keys in a table definition. The following are common options.
Restrict
Don't allow parent rows to be deleted or their primary key updated. In this case, you need to update the foreign keys of child rows before deleting the parent.
Null
When a parent row is deleted or updated, set related foreign keys to null.
Default
When a parent row is deleted or updated, set related foreign keys to a default value.
Cascade
When a parent row is updated, related foreign keys are updated. When a parent row is deleted, child rows are deleted.
Complex
Databases may support complex custom rules for referential integrity such as performing different actions depending on the value of the key.

Example

An Employee table has a OFFICE_ID foreign key that refers to the primary key of the OFFICE table. The data definition instructs the database if an OFFICE is deleted to set all related Employee rows to a default that points to the head office of the firm.
Overview: Referential Integrity
TypeDatabases
DefinitionThe validity of relations in a database.
Related ConceptsForeign Key
Primary Key
Databases

IT Skills

This is the complete list of articles we have written about it skills.
Algorithms
Analytics
Architecture
Artificial Intelligence
Automation
Big Data
Coding
CRM
Data
Data Mining
Databases
Design
Devops
ERP
Gamification
Information Security
IT Examples
Legacy Software
Office Productivity
Problem Management
Process Automation
Robotics
SCM
Service Delivery
Service Management
Software Design
Testing
If you enjoyed this page, please consider bookmarking Simplicable.
 

Databases

A list of database terms.

Primary Key vs Candidate Key

The difference between primary key and candidate key including an example.

Atomicity

The definition of atomicity with common examples.

Operational Database

A definition of operational database with examples.

Database Skills

A list of common database skills.

Row vs Column

The difference between row and column explained with examples.

Data

An overview of data with a list of examples.

Types Of Data

The basic types of data.

Dark Data

The definition of dark data with examples.

Data Definition

Several useful definitions of data.

Analytics

A definition of analytics with examples.

Data vs Information

The difference between data and information.

Hard Data vs Soft Data

The difference between hard data and soft data.

Human Readable

A definition of human readable.

Data Loss

The common types of data loss.
The most popular articles on Simplicable in the past day.

New Articles

Recent posts or updates on Simplicable.
Site Map