NEW
Database property ensuring foreign key values reference existing parent rows, maintaining consistent relationships across tables.
DESCRIPTION
Referential integrity enforces valid relationships between tables via foreign keys. It prevents orphan records and ensures consistent joins. RDBMSs offer constraint options like ON DELETE or ON UPDATE CASCADE to maintain data integrity. Modeling requires careful key design, indexing, and transactional updates. While many NoSQL systems lack native constraints, applications can emulate integrity at the service layer. Violations indicate schema or process issues, often revealed by integrity checks and testing.
ALTERNATIVE DEFINITIONS
Wikipedia
Referential integrity is a property of data which, when satisfied, requires that every value of one attribute (column) of a relation (table) be a valid value of another attribute in a different (or the same) relation.
States the property in terms of relational attributes and valid references.
PostgreSQL
A foreign key constraint specifies that the values in a column (or a group of columns) must match the values appearing in some row of another table.
Vendor documentation explaining foreign key constraints enforcing referential integrity.
Microsoft Learn
A foreign key is a column or combination of columns used to establish and enforce a link between the data in two tables.
Clarifies enforcement of links between tables via foreign keys.
RELATED TERMS
Foreign Key Primary Key Database Constraint Cascading Delete Feature Scaling ER Modeling Transaction ACID Schema Design Data Consistency
COMPETING TERMS
Application-level Integrity
KNOWLEDGE AREAS
Data Modeling Data Storage & Operations Data Architecture
TARGET AUDIENCE
Data Engineer Software Developer Data Modeler Data Architect
EXTERNAL SOURCES
- Wikipedia - Referential integrity
- PostgreSQL - Foreign key constraints docs
- MySQL - MySQL foreign key constraints
- Microsoft - SQL Server foreign key docs
- SQLite - SQLite foreign key support
TOP QUESTIONS
Why is Referential Integrity important?
It prevents orphan records, ensures consistent joins, and maintains trustworthy relational data for analytics and operations.
Category: Relevancy
How do ON DELETE and ON UPDATE actions affect Referential Integrity?
Cascade actions propagate changes to child tables; restrict or no action prevents updates that would break integrity.
Category: Example
What is a common mistake when implementing Referential Integrity?
Missing indexes on foreign keys degrades performance and can cause lock contention during updates.
Category: Mistakes
Can NoSQL databases enforce Referential Integrity?
Many do not natively; applications must enforce integrity through service-layer checks and transactional patterns.
Category: Misunderstanding
How do you test Referential Integrity?
Use constraint checks, integrity queries, and migration tests to confirm all foreign keys reference valid primary keys.
Category: Requirements
What risks arise from broken Referential Integrity?
Inconsistent analytics, data corruption, and failed joins lead to incorrect decisions and operational errors.
Category: Risks
How is Referential Integrity documented?
ER diagrams, schema DDL, and data dictionaries record foreign key relationships and constraints.
Category: Management
What is the biggest misunderstanding about Referential Integrity?
Believing application logic alone suffices; database constraints provide necessary enforcement and protection.
Category: Misunderstanding
Where to start learning Referential Integrity?
Read database vendor docs on foreign keys and practice with simple parent-child schema examples.
Category: Example