Tables, Keys & Constraints · Question 20 · Hard
In standard SQL, which column(s) of the parent table may a FOREIGN KEY reference?
- Column(s) declared as the PRIMARY KEY or as UNIQUE
- Only the PRIMARY KEY
- Any column that is declared NOT NULL
- 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
- Emp.dept_id is declared as FOREIGN KEY REFERENCES Dept(id) with no ON DELETE…
- The status column has a DEFAULT, but this INSERT passes NULL for it…
- The four INSERT statements run one after another. Which of them is the first…
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