Tables, Keys & Constraints · Question 20 · Hard

In standard SQL, which column(s) of the parent table may a FOREIGN KEY reference?

  1. Column(s) declared as the PRIMARY KEY or as UNIQUE
  2. Only the PRIMARY KEY
  3. Any column that is declared NOT NULL
  4. Any column that has an index, unique or not
Answer and explanation

Answer: A. Column(s) declared as the PRIMARY KEY or as UNIQUE

Explanation: Each foreign key value must point to exactly one parent row, so the referenced column(s) must be guaranteed unique. That means the primary key or a column set with a UNIQUE constraint; NOT NULL alone does not make values unique.

Previous: The four INSERT statements run one after another. Which of them is the first…

Practise tables, keys & constraints

Try a fresh set of tables, keys & constraints questions with an explanation after every answer, free and without signing up: Tables, Keys & Constraints practice. Or sit a full placement mock test.

More tables, keys & constraints questions

More sql practice

DML & Transactions · SELECT, WHERE & ORDER BY · SQL Joins · Aggregates & GROUP BY · Subqueries & CTEs · Window Functions · NULL Handling · SQL Functions & CASE

LogicWiz Exams home · All practice topics · Placement mock tests · Daily 10 challenge