DA0-002 Data Concepts and Environments Practice Question
A retail company wants to analyze customer purchase patterns over time. The data is stored in a relational database with tables for Customers, Orders, and Products. Which database concept should be used to ensure that each order references a valid customer?
⚠ Common exam trap
CompTIA often tests the distinction between a primary key (which enforces uniqueness within a table) and a foreign key (which enforces relationships between tables), leading candidates to mistakenly choose primary key when the question asks about cross-table validation.
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
✓
Foreign key
A foreign key constraint enforces referential integrity by ensuring that every value in the 'customer_id' column of the Orders table matches a valid primary key value in the Customers table. This prevents orphaned records and guarantees that each order references an existing customer.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
View
Why it's wrong here
A view is a stored SELECT that presents data virtually; it stores no constraint, so an order can still reference a missing customer. It tempts because views are used to simplify joins between Customers, Orders and Products for reporting, which would suit this scenario if the requirement were presentation rather than referential integrity.
- ✗
Index
Why it's wrong here
An index accelerates row lookups on a column; it enforces no referential rule, so an order could still cite a non-existent customer. It is tempting because indexes are commonly added to foreign-key columns for join performance, and that would be the right choice when the goal is query speed rather than validity.
- ✗
Primary key
Why it's wrong here
A primary key uniquely identifies each row in its own table; it does not enforce that Orders.customer_id matches an existing Customers row. It would be correct for uniquely identifying customers, but referential integrity across the two tables requires a foreign key.
- ✓
Foreign key
Why this is correct
A foreign key constrains the Orders table's customer reference to values existing in the Customers primary key, enforcing referential integrity so no order can point at an invalid customer. This directly prevents orphaned order records.
Go deeper
Related to this question
About these practice questions
One of 1,004 original DA0-002 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This DA0-002 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 DA0-002 exam.