QuizzesPrimary Key & Foreign Key Constraints — Concept Check
intermediate
sql

Primary Key & Foreign Key Constraints — Concept Check

Questions on Primary Key & Foreign Key Constraints. A primary key uniquely identifies each row; a foreign key enforces referential integrity by linking a column to the primary key of another table.

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 Primary Key & Foreign Key Constraints — Concept Check. Work through them here, then start the quiz to answer them and see your score.

  1. 1.A database administrator notices orphaned rows in a microservice database. What might be the cause?

    • AComposite primary keys were used instead of surrogate keys.
    • BON DELETE CASCADE was used inappropriately.
    • CPrimary key constraints were incorrectly defined.
    • DForeign key constraints were skipped for performance reasons.
  2. 2.In a database, what happens to child rows when a parent row is deleted with ON DELETE SET NULL?

    • AChild rows' foreign key columns are set to NULL.
    • BAn error is raised, preventing the deletion.
    • CThe deletion is postponed until the transaction ends.
    • DChild rows are also deleted.
  3. 3.A developer uses a composite primary key for a surrogate-key table. What is a potential issue?

    • AIt makes foreign key references verbose.
    • BIt requires a unique constraint on the natural key.
    • CIt prevents the use of ON DELETE CASCADE.
    • DIt causes data corruption in microservices.
  4. 4.What is the default behavior when a foreign key's referenced row is deleted without specifying ON DELETE?

    • ANO ACTION
    • BRESTRICT
    • CSET NULL
    • DCASCADE
  5. 5.A product is uncategorized after its category is deleted. Which referential action is likely used?

    • AON DELETE CASCADE
    • BON DELETE SET NULL
    • CON DELETE RESTRICT
    • DON DELETE NO ACTION
  6. 6.A team avoids foreign keys for performance, believing they slow down queries. What is a likely consequence?

    • AIncreased database size.
    • BData integrity issues due to orphaned rows.
    • CSimpler schema design.
    • DImproved query performance.
  7. 7.What does a primary key constraint ensure in a database table?

    • AAutomatic foreign key creation.
    • BReferential integrity with other tables.
    • CUniqueness and non-nullability of each row.
    • DAutomatic data indexing.
  8. 8.In JPA, what does the @ManyToOne annotation represent in terms of database constraints?

    • AAn index creation.
    • BA composite key relationship.
    • CA foreign key relationship.
    • DA primary key constraint.