QuizzesForeign Keys & Referential Integrity — Concept Check
intermediate
mysql

Foreign Keys & Referential Integrity — Concept Check

Questions on Foreign Keys & Referential Integrity. InnoDB foreign keys enforce parent-child integrity with ON DELETE/UPDATE CASCADE, SET NULL, or RESTRICT; always index the FK column to avoid full-table scans on parent updates.

8 minutes 8 questions Pass at 70%
Time Limit
8 minutes - timer starts when you begin
Change Answers Freely
Revisit and change any answer before submitting
Full Review After Submit
Correct answers and explanations shown for every question
Auto-submit on timeout
Quiz submits automatically when time runs out

Questions in this quiz

8 questions on Foreign Keys & Referential Integrity — Concept Check. Work through them here, then start the quiz to answer them and see your score.

  1. 1.A database administrator notices that deleting a customer record fails because the customer has associated orders. What is the likely cause?

    • AON DELETE SET NULL is set on the foreign key
    • BON DELETE RESTRICT is set on the foreign key
    • CThe foreign key is not indexed
    • DON DELETE CASCADE is set on the foreign key
  2. 2.When updating a parent record's primary key, which foreign key option ensures that child records are updated automatically?

    • AON UPDATE CASCADE
    • BON UPDATE NO ACTION
    • CON UPDATE RESTRICT
    • DON UPDATE SET NULL
  3. 3.A developer disables foreign key checks to speed up a bulk data load but forgets to re-enable them. What is a potential consequence?

    • AForeign keys will be deleted
    • BOrphaned child records may exist
    • CIndexes will be corrupted
    • DData load will be slower
  4. 4.What happens if a foreign key column in a child table is not indexed when a parent record is updated?

    • AThe update is rejected
    • BThe child table is locked
    • CThe foreign key is automatically indexed
    • DA full table scan occurs on the child table
  5. 5.In a deadlock scenario involving foreign keys, what is a recommended practice to avoid deadlocks?

    • AUse ON DELETE CASCADE
    • BAvoid indexing foreign keys
    • CDisable foreign key checks
    • DUpdate parent and insert child in the same transaction order
  6. 6.A developer sets ON DELETE SET NULL on a foreign key. What must be true for this to work?

    • AThe foreign key column must be unique
    • BThe foreign key column must be nullable
    • CThe child table must have no other foreign keys
    • DThe parent table must have a composite key
  7. 7.What is the default behavior of a foreign key in InnoDB when a parent record is deleted?

    • ASet child foreign keys to NULL
    • BReject the deletion if child records exist
    • CAutomatically delete child records
    • DDefer the deletion check
  8. 8.A developer mistakenly believes that ON DELETE CASCADE will set foreign key columns to NULL. What is the correct behavior?

    • AON DELETE CASCADE deletes child records
    • BON DELETE CASCADE defers deletion
    • CON DELETE CASCADE does nothing
    • DON DELETE CASCADE sets foreign key columns to NULL