All Questions
Data Modeling hard

You are doing high-concurrency inserts into a `Child` table with a Foreign Key to `Parent`. Why might this cause deadlocks on the `Parent` table?

  1. A To verify the constraint, the database must acquire a Shared (Read) Lock on the Parent row; if multiple transactions then attempt to update that Parent simultaneously, deadlocks occur.
  2. B The database hardware is forced to acquire an exclusive lock on the entire Parent table for every single child insert operation to ensure that no data corruption can take place.
  3. C The presence of a Foreign Key automatically disables the database's ability to perform row-level locking, forcing the system to revert to a less efficient, page-level locking model.
  4. D Foreign Keys strictly limit the maximum total volume of the child table, and once this threshold is crossed, the database enters a global block state until old records are purged.

One system design question a day, with spaced repetition so the ones you miss come back.

Get the app

Related questions