Foreign Keys
Define relational constraints between custom tables using foreign keys.
A foreign key is a database-level constraint that links a column in one table to the primary key of another table. Foreign keys enforce referential integrity: you cannot create a record in the child table that references a non-existent record in the parent table, and you can control what happens when a parent record is deleted or updated.
Foreign keys are configured in Step 4 of the table wizard.
Creating a foreign key
Open the table wizard and navigate to Step 4 — Foreign Keys.
Click Add foreign key.
Fill in the constraint settings:
Constraint name
Unique identifier for this FK constraint (e.g. fk_movies_director).
Local column
The column in this table that holds the reference (e.g. director_id).
Reference table
The parent table (e.g. directors).
Reference column
The column in the parent table being referenced (usually id).
On delete
Action when the parent record is deleted (see actions below).
On update
Action when the parent key value is updated.
Referential actions
CASCADE
Automatically delete or update the child rows when the parent row is deleted/updated.
SET NULL
Set the foreign key column to NULL when the parent row is deleted/updated. Requires the column to be nullable.
RESTRICT
Prevent deletion/update of the parent row while child rows still reference it.
NO ACTION
Same as RESTRICT in MySQL (checked at the end of the statement).
(SET DEFAULT is not offered — InnoDB parses but ignores it.)
Example — Movies and Directors
A movies table references a directors table:
Constraint name
fk_movies_director_id
Local column
director_id
Reference table
directors
Reference column
id
On delete
SET NULL
On update
CASCADE

This means:
A movie's
director_idmust match a valididindirectors.If a director is deleted, all their movies have
director_idset toNULL(the movie is preserved but orphaned).If a director's
idchanges, thedirector_idin all related movies is updated automatically.
Deleting a foreign key
Click Delete next to the constraint in Step 4. The constraint is dropped from the database the next time the schema is synced.
See also
Relational fields — for the UI-level relationship experience (linking records across tables via the admin form)
Last updated