Microsoft Azure Data FundamentalsDescribe how to work with relational data on AzureEasy
A data architect is designing a relational database in Azure. They need to ensure that when a row in a parent table is deleted, all corresponding rows in a child table are also automatically deleted to maintain data integrity. Which referential integrity action should be configured on the foreign key constraint?
- ANO ACTION
- BSET NULL
- CCASCADE
- DSET DEFAULT
Show answer & explanationAnswer & explanation
Correct answer: C. CASCADE
The CASCADE referential integrity action ensures that when a row in the parent table is deleted, all dependent rows in the child table are also deleted, maintaining consistency.
Why the other options are wrong
- A. NO ACTION prevents the deletion of the parent row if there are dependent child rows.
- B. SET NULL sets the foreign key columns in the child table to NULL when the parent row is deleted.
- D. SET DEFAULT sets the foreign key columns in the child table to their default values when the parent row is deleted.
CASCADE Referential Integrity
A referential integrity action that automatically deletes dependent child rows when the corresponding parent row is deleted from the parent table.
- Ensures data consistency across related tables.
- Configured on foreign key constraints.
- Prevents orphaned records in child tables.
Memory trick: Cascade: Parent's fall, children cascade.