Which approach enforces referential integrity in a relational database?

Get ready for the GMetrix Data Modeling Test. Enhance your skills with flashcards and multiple choice questions, complete with hints and explanations. Prepare effectively for success!

Multiple Choice

Which approach enforces referential integrity in a relational database?

Explanation:
Referential integrity means that a value in a foreign key must correspond to an existing value in the related table’s primary key, so you don’t end up with references to nowhere. The reliable way to enforce this is to declare a foreign key constraint that points to the primary key of the parent table and define how updates or deletes should be handled (for example, cascade, restrict, or set null). This built-in mechanism automatically prevents inserting invalid foreign keys and keeps related rows in sync when changes occur, ensuring the relationship remains valid across both tables. Data type constraints on keys help ensure the values have the right type, but they don’t enforce the cross-table link between a child row and its parent row. Indexing all columns improves query performance but does not enforce referential links. Trigger-based replication or checks can enforce rules in some cases, but they’re not as reliable or centralized for maintaining core relationships as foreign key constraints with defined update/delete actions.

Referential integrity means that a value in a foreign key must correspond to an existing value in the related table’s primary key, so you don’t end up with references to nowhere. The reliable way to enforce this is to declare a foreign key constraint that points to the primary key of the parent table and define how updates or deletes should be handled (for example, cascade, restrict, or set null). This built-in mechanism automatically prevents inserting invalid foreign keys and keeps related rows in sync when changes occur, ensuring the relationship remains valid across both tables.

Data type constraints on keys help ensure the values have the right type, but they don’t enforce the cross-table link between a child row and its parent row. Indexing all columns improves query performance but does not enforce referential links. Trigger-based replication or checks can enforce rules in some cases, but they’re not as reliable or centralized for maintaining core relationships as foreign key constraints with defined update/delete actions.

Subscribe

Get the latest from Passetra

You can unsubscribe at any time. Read our privacy policy