What is a foreign key?

SQL keys and table design · Freshers

Model answer

A column that refers to the primary key of another table, enforcing that the referenced row exists: orders.customer_id references customers.id. It protects data consistency and can define what happens on delete (CASCADE, SET NULL, RESTRICT).

Learn this topic

Keys and Table Design: Why Data Is Split Into Tables in the course SQL for Beginners: Learn Databases Step by Step.

Sign in to add your own answer.

More questions