Practice mode DBMS and SQL

Emp.dept_id is a foreign key referencing Dept(id), declared with no ON DELETE action. What happens if you try to delete a Dept row that some Emp rows still reference?

Correct answer D. The delete is rejected with a foreign key violation

Explanation

When no ON DELETE clause is given, the default action is NO ACTION, which behaves like RESTRICT for a simple delete: the DBMS refuses the delete because it would leave dangling references. Deleting the child rows happens only with ON DELETE CASCADE, and setting them to NULL needs ON DELETE SET NULL. Leaving orphans pointing to a missing row is exactly what referential integrity forbids.

Report a problem

Answer checked How we write and check questions

Tip: press A, B, C or D to answer, and N for the next question.

Advertisement

Have a question about this answer?

Your email address will not be published. Required fields are marked *

Links and website addresses are not allowed in comments.