A developer needs to ensure that a 'Customer_ID' field in a 'Orders' table always references a valid ID in the 'Customers' table. Which constraint should be applied?
A FOREIGN KEY enforces referential integrity by requiring every Customer_ID value in Orders to match an existing primary key in Customers, rejecting inserts or updates that reference a non-existent customer. This directly satisfies the stem's requirement that the field always reference a valid ID.
Why this answer
A FOREIGN KEY constraint is used to enforce referential integrity between two tables. It ensures that the Customer_ID in the Orders table matches an existing ID in the Customers table, preventing orphaned records and maintaining consistent relationships.
Exam trap
DS0-001 often tests the confusion between PRIMARY KEY (uniqueness within a table) and FOREIGN KEY (referential integrity across tables), catching candidates who overlook the cross-table requirement.
How to eliminate wrong answers
Option A is wrong because a PRIMARY KEY uniquely identifies each row in its own table and cannot reference another table. Option B is wrong because a UNIQUE constraint ensures uniqueness within a single table but does not enforce cross-table references. Option C is wrong because a CHECK constraint validates data against a logical expression (e.g., range or format) but cannot reference another table's data.