MySQL Database

MySQL Foreign Key

Enforce a relationship between related tables.

CREATE TABLE orders (
  id INT PRIMARY KEY,
  customer_id INT,
  FOREIGN KEY (customer_id) REFERENCES customers(id)
);

The referenced value must exist in the parent table, preserving referential integrity.