juniorSQL

What is a foreign key?

Updated May 17, 2026

Short answer

Foreign key links two tables.

Deep explanation

It ensures referential integrity between parent and child tables.

Real-world example

Orders linked to users.

Common mistakes

  • Inserting invalid referenced keys.

Follow-up questions

  • What is cascading delete?
  • Can foreign key be NULL?

More SQL interview questions

View all →