FOREIGN KEY ... REFERENCES in CREATE TABLE
Used in CREATE TABLE to link a column to another table's key. The database then only accepts values that match an existing key, so bad links are rejected.
Understanding FOREIGN KEY ... REFERENCES in CREATE TABLE in ACARA Digital Technologies Years 9–10
What it does: students is created before orders, so when orders names students(studentId) that table and key already exist. The column in this table goes in the first brackets. After REFERENCES comes the other table's name, then its key in brackets. A foreign key column should have the same data type as the key it references, so the values can be compared and matched. The constraint enforces the link. It is not just a comment, so bad links are rejected. The database never creates rows in the other table for you. With no matching key, the insert is rejected.
Common mistakes: The keyword is missing KEY. A foreign key is declared with FOREIGN KEY (student_id), followed by REFERENCES. The foreign key column must have the same data type as the key it references. students(id) is an INT, so student_id must be INT, not VARCHAR.
Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.
This module's key terms are also in a printable crossword (Modules 433–451) and word search (Modules 413–451).
Take this worksheet further — free with Cloodit
Each concept is reinforced from every angle — learned, then applied, then tested.
Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.
Over 100 of them, across seven natural biomes.
Turns their work into revision material ready for Flash Cards and Exam study.
Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.
Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.
Quick Questions
Match the Pairs
Key Term
FOREIGN KEY (field) REFERENCES other_table(field)Fill in the Blanks
Spot the Error
Student with a class code? Join your class →