# Referential Integrity

The rule that foreign-key values must reference an existing allowed key or be NULL when permitted.

## What is **Referential Integrity** in a relational database?

**Referential Integrity** — The rule that foreign-key values must reference an existing allowed key or be NULL when permitted.

```sql
CREATE TABLE purchase_order (
    order_id INTEGER PRIMARY KEY,
    customer_id INTEGER REFERENCES customer (customer_id)
);
```

Level: Journeyman · [More Database terms at this level](https://www.ask-codey.com/glossary/subjects/database/journeyman)

Updated: September 27, 2026

Source: https://www.ask-codey.com/glossary/referential-integrity
