Referential Integrity

noun

say it: “ref-uh-REN-shul in-TEG-rih-tee” /ˌrɛfəˈrɛnʃəl ɪnˈtɛɡrɪti/

The rule that every foreign key in a table points at a row that really exists, so no row is left pointing at nothing.

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.

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

In a sentence

  • “Referential integrity stopped a product from naming vendor 99, who doesn't exist.”
  • “Turning on foreign keys in SQLite is what enforces referential integrity.”

Level: Journeyman · More Database terms at this level

Updated