Skip to content
SQLSimplified
BackendQuestion 22 of 52

Unindexed Foreign Keys

Problem

Deleting a parent department row is locking the entire child employee table and causing timeouts. You explain that deleting a parent record triggers a check on the child table, requiring a sequential scan if the foreign key is not indexed. Write a query that outputs fix with the value: "Indexing foreign key columns in child tables prevents table locks and scans when parent records are updated or deleted."

Database Schema

This problem acts as a scratchpad. You will write your own DDL/DML or conceptual queries, so there is no predefined schema.

Try It

Loading playground environment...

Hint

Solution