Complete FOREIGN KEY
Fill in the Blank Easy
Question
Fill in the blank to make user_id reference the users table:
Code
CREATE TABLE orders (
id SERIAL PRIMARY KEY,
user_id INTEGER ___ users(id)
);
Hint
This keyword points to another table's primary key.
Explanation
REFERENCES creates a foreign key constraint. user_id INTEGER REFERENCES users(id) means user_id must reference an existing id in the users table.
Related Resources
Related Lessons
- Relationships
Learn foreign keys.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.