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

What is Referential Integrity?

 , updated on
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
Type
Definition
The validity of relations in a database.
Related Concepts
More about databases:
Atomicity
Database Index
Candidate Key
Databases
Data Purging
Dataset
Foreign Key
Federated Databases
Primary Key
Operational Database
Referential Integrity
Unique Constraint
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.

Social Data

An overview of social data with examples.

Information Things

A list of things that can be considered information.

IT Gaps

An overview of IT gaps with examples.

Data Quality Examples

An overview of data quality with examples.

Legacy Data

An overview of legacy data with examples.

Customer Analytics

An overview of customer analytics with examples.

Uncertainty Principle

An overview of the uncertainty principle with examples.

Regression Analysis

An overview of regression analysis with examples.

Unstructured Data

A definition of unstructured data with examples.
The most popular articles on Simplicable in the past day.

New Articles

Recent posts or updates on Simplicable.
Site Map