Explain foreign keys and referential integrity

SQL
Easy
91.5K views

This question tests relationship enforcement. It evaluates data consistency strategies.

Why Interviewers Ask This

Foreign keys prevent orphaned data. Interviewers check if you understand how relationships are enforced automatically.

How to Answer This Question

Define FK as a column referencing a parent key. Explain it prevents orphan rows. Mention actions on delete/update.

Key Points to Cover

  • References parent key
  • Prevents orphan rows
  • Enforces integrity
  • Child-Parent relationship

Sample Answer

A foreign key is a column in a child table that references a primary key in a parent table. It enforces referential integrity by preventing actions that would create orphan rows, ensuring child values actually exist in the parent.

Common Mistakes to Avoid

  • Thinking FK creates data
  • Ignoring cascade rules
  • Confusing with primary key

Practice This Question with AI

Answer this question orally or via text and get instant AI-powered feedback on your response quality, structure, and delivery.

Start Practicing

Related Interview Questions

Browse all 49 SQL questions