Referential integrity
Referential integrity is the property that references between related data records or relations correspond to valid, existing keys or records.
Build Financial Software with Generative AI (From Scratch)
Referential integrity is a database property that requires references between related records to remain valid and prevents references to nonexistent records.
- How it is used
- Uses referential integrity to keep related ACH file records consistent in a relational database.
- How deep it goes
- Works through foreign keys, cascade rules, and test changes, including errors exposed by a schema revision.
- Examples
- Uses ACH file and record tables, a batch hierarchy, and failing insertion tests to illustrate relationships.
- What you can do after
- Apply it via PostgreSQL by defining foreign keys and cascade rules and updating test setup for valid parent records.
Read how Build Financial Software with Generative AI (From Scratch) explains referential integrity →
Grokking Relational Database Design
The property that references between related tables remain valid and consistent as rows are inserted, updated, or deleted.
- How it is used
- Protects related-table data during inserts, updates, and deletions with foreign key constraints.
- How deep it goes
- Defines parent-child validation, constraint naming, mandatory relationships, and update/delete actions including RESTRICT, CASCADE, and SET NULL.
- Examples
- Uses product-review, user-review, and payment-method-user table relationships, including rejected invalid review insertion.
- What you can do after
- Build it from scratch with named FOREIGN KEY ... REFERENCES constraints and appropriate update/delete actions.
Read how Grokking Relational Database Design explains referential integrity →
API Design Patterns
Referential integrity is the property that references remain valid and continue to identify the intended existing resources or data.
- How it is used
- Defines how APIs behave when resources referenced by other resources are deleted, moved, copied, or soft-deleted.
- How deep it goes
- Compares four deletion policies and explains write avalanches, deletion cascades, dangling pointers, moves, and soft-deletion consistency.
- Examples
- Uses MessageReviewReport.messageId, moved Message and ChatRoom resources, and four standardized deletion behaviors.
- What you can do after
- Evaluate deletion and movement policies, then configure API behavior that either restricts references or deliberately leaves them for consumers.
Read how API Design Patterns explains referential integrity →
100 SQL Server Mistakes and How to Avoid Them
Referential integrity is the property that relationships between tables contain only references to existing valid key values.
- How it is used
- Prevents invalid references between related tables during schema design and everyday data changes.
- How deep it goes
- Defines the property, demonstrates its failure, and shows repair and constraint-creation SQL without descending into constraint internals.
- Examples
- Uses Employees and Offices, plus MagicChoc purchase-order headers and details, to demonstrate valid and invalid references.
- What you can do after
- Operate/configure relational schemas by repairing invalid values and adding foreign key constraints with T-SQL.
Read how 100 SQL Server Mistakes and How to Avoid Them explains referential integrity →
Also covered in
- The Cloud at Your Service: The when, how, and why of enterprise cloud computing
- Learn SQL in a Month of Lunches
What to know first
- missing valueA missing value is an expected data value or observation that is absent, unavailable, unknown, or inapplicable.
- data integrityData integrity is the property of data being accurate, complete, consistent, and valid throughout its storage, processing, and transfer.
- foreign keyA foreign key is a column or set of columns whose values reference a key in the same or another relational table, linking records and supporting referential integrity.
- SQLSQL is a standardized declarative language for defining, querying, and manipulating data in relational database systems.
Related concepts
- foreign keyimplemented by · A foreign key is a column or set of columns whose values reference a key in the same or another relational table, linking records and supporting referential integrity.
- primary keyproduced by · A primary key is a field or combination of fields whose values uniquely identify each row or item in a data store.
- soft deleteused by · Soft deletion is a technique that marks data as deleted while retaining it in storage rather than immediately removing it physically.
- ScyllaDBcontrasts with · ScyllaDB is a distributed wide-column database compatible with Cassandra’s data model and protocol, designed for high scalability and availability.
- referencemeasures · A reference is an indirect value, binding, or relationship that identifies or provides access to another object, value, resource, or source.
- databaseused by · A database is an organized persistent data store, typically managed by software, that supports storing, retrieving, and modifying data.
Questions about referential integrity
What is referential integrity?
Referential integrity is the property that references between related data records or relations correspond to valid, existing keys or records.
Which Manning books explain referential integrity?
Build Financial Software with Generative AI (From Scratch), Grokking Relational Database Design, API Design Patterns and 100 SQL Server Mistakes and How to Avoid Them.
What should I know before learning referential integrity?
Manning books that teach referential integrity usually introduce missing value, data integrity, foreign key and SQL first.
What is the difference between referential integrity and ScyllaDB?
Referential integrity is the property that references between related data records or relations correspond to valid, existing keys or records. ScyllaDB is a distributed wide-column database compatible with Cassandra’s data model and protocol, designed for high scalability and availability.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.



