How does a properly implemented foreign key constraint contribute to the…
2025
How does a properly implemented foreign key constraint contribute to the consistency property in a database transaction?
- A.
By ensuring that all inserted rows are committed immediately
- B.
By ensuring that a referenced record exists in the parent table
- C.
By automatically removing orphan records during insertion
- D.
By allowing duplicate values in the referencing column
Attempted by 202 students.
Show answer & explanation
Correct answer: B
A foreign key enforces referential integrity, which directly supports the Consistency (C) property of ACID transactions. It guarantees that a child table cannot reference a non-existent value in the parent table. If a transaction attempts to insert an invalid reference or delete a parent record that still has active child records, the database engine automatically rejects the transaction, preventing data corruption and keeping the system in a valid state.