Recall & Review
beginner
What is a foreign key in a database?
A foreign key is a column or set of columns in one table that refers to the primary key in another table. It creates a link between the two tables.
Click to reveal answer
beginner
Why do we use foreign keys?
Foreign keys help keep data consistent by ensuring that the value in one table matches a value in another table. This prevents errors like referencing a non-existent record.
Click to reveal answer
intermediate
How does a foreign key create a mental model of linking tables?
Think of a foreign key as a bridge connecting two tables. It helps you understand how data in one table relates to data in another, like linking a customer to their orders.
Click to reveal answer
intermediate
What happens if you try to insert a foreign key value that doesn't exist in the referenced table?
The database will reject the insert because it violates the foreign key constraint. This keeps data accurate and linked properly.
Click to reveal answer
intermediate
Can a foreign key be null? What does that mean?
Yes, a foreign key can be null if the relationship is optional. It means the record doesn't currently link to any record in the other table.
Click to reveal answer
What does a foreign key in a table do?
✗ Incorrect
A foreign key links to a primary key in another table to create a relationship.
What happens if you insert a foreign key value that does not exist in the referenced table?
✗ Incorrect
The database rejects the insert to maintain data integrity.
Which of these best describes a foreign key?
✗ Incorrect
A foreign key links to another table's primary key to connect data.
Can a foreign key column contain NULL values?
✗ Incorrect
Foreign keys can be NULL to indicate no current link.
What is the main purpose of a foreign key constraint?
✗ Incorrect
Foreign key constraints ensure data stays consistent and linked.
Explain in your own words how a foreign key links two tables in a database.
Think about how one table points to another like a bridge.
You got /3 concepts.
Describe what happens if you try to add a record with a foreign key value that does not exist in the referenced table.
Consider the database's role in keeping data accurate.
You got /3 concepts.