Courseiva
mediumMultiple Select

FC0-U71 Practice Question: A database designer wants to enforce that a…

A database designer wants to enforce that a 'CustomerID' value in an 'Orders' table must exist in the 'Customers' table. Which TWO methods can achieve this?

⚠ Common exam trap

Candidates often confuse a primary key or unique constraint with referential integrity, thinking that ensuring uniqueness in the parent table automatically enforces existence in the child table, but neither does so without an explicit foreign key or trigger.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

Use a trigger to check existence

Option E is correct because a FOREIGN KEY constraint from Orders.CustomerID referencing Customers.CustomerID is the declarative, purpose-built mechanism for enforcing referential integrity, ensuring every Orders.CustomerID value matches an existing Customers.CustomerID value (or is NULL if allowed). Option C is correct because a trigger (e.g., a BEFORE INSERT/UPDATE trigger that queries Customers for the given CustomerID and raises an error if absent) can also enforce this existence check, which is useful when the referenced column lacks a unique/primary key constraint or when custom logic is needed. Option A is wrong because a UNIQUE constraint on Orders.CustomerID only prevents duplicate values in Orders; it does not verify that the value exists in Customers. Option B is wrong because an index merely speeds up lookups and enforces no referential rule. Option D is wrong because a PRIMARY KEY on Customers.CustomerID guarantees uniqueness in Customers but does not, by itself, constrain or validate the values stored in Orders.CustomerID.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✗

    Create a unique constraint on Orders.CustomerID

    Why it's wrong here

    A unique constraint on Orders.CustomerID only prevents duplicate customer values within Orders; it permits values absent from Customers, so referential integrity is not enforced. Unique constraints are the correct choice when the requirement is preventing duplicate rows in the same table.

  • ✗

    Create an index on Orders.CustomerID

    Why it's wrong here

    An index on Orders.CustomerID accelerates lookups and joins but imposes no restriction, so an Orders row may still reference a nonexistent customer. Indexes are the correct choice when the requirement is query performance rather than enforcing referential integrity between tables.

  • ✓

    Use a trigger to check existence

    Why this is correct

    A trigger can query the Customers table before allowing an insert or update on Orders, rejecting rows whose CustomerID has no match. This enforces the required referential constraint at the application layer, satisfying the stem's demand that every CustomerID value must already exist in Customers.

  • ✗

    Create a primary key on Customers.CustomerID

    Why it's wrong here

    A primary key on Customers.CustomerID enforces uniqueness and non-nullness within Customers, but creates no link to Orders, so orphan CustomerID values there remain permitted. Primary keys are correct when the requirement is uniquely identifying each row of the parent table itself.

  • ✓

    Create a foreign key from Orders.CustomerID to Customers.CustomerID

    Why this is correct

    A foreign key constraint enforces referential integrity at the database engine level, rejecting any Orders row whose CustomerID lacks a matching Customers.CustomerID. This directly satisfies the stem's requirement that the value must exist in the parent table, providing automatic enforcement without application code or triggers.

About these practice questions

This FC0-U71 question is part of Courseiva's 988-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This FC0-U71 practice question is part of Courseiva's free CompTIA certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the FC0-U71 exam.