Courseiva

DA0-002 Data Concepts and Environments Practice Question

A healthcare database stores patient records. Each patient has a unique patient_id, and the database includes a table 'visits' with visit_id, patient_id, visit_date, and diagnosis_code. To ensure data integrity, which constraint should be applied to the patient_id column in the 'visits' table?

⚠ Common exam trap

DA0-002 often tests the confusion between primary key, unique, and foreign key constraints, where candidates incorrectly apply uniqueness to a column that should allow duplicates but reference another table.

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 on patient_id in the visits table enforces referential integrity by ensuring every patient_id value in visits matches an existing patient_id in the patients table. This prevents orphaned visit records and maintains consistency between the two tables.

Answer analysis

Option-by-option breakdown

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

  • ✗

    Unique constraint

    Why it's wrong here

    A unique constraint would permit only one visit row per patient_id, breaking the one-to-many relationship between patients and visits. It tempts because patient_id is unique in the patients table, but in visits it is a foreign key referencing patients(patient_id), enforcing referential integrity.

  • ✓

    Foreign key

    Why this is correct

    A foreign key on patient_id in the visits table references the primary key in the patients table, ensuring every visit maps to an existing patient. This enforces referential integrity, preventing orphan visit records, which is the integrity requirement stated in the stem.

  • ✗

    Primary key

    Why it's wrong here

    A primary key enforces uniqueness, but patient_id repeats across a patient's many visits, so it would reject legitimate rows. It is tempting because patient_id uniquely identifies a patient in the patients table, yet within visits the unique identifier is visit_id.

  • ✗

    Check constraint

    Why it's wrong here

    A check constraint validates values against a condition, not referential existence, so it cannot guarantee each patient_id matches a real patient. It is tempting because it enforces domain rules such as ranges, which suits validating diagnosis codes, not linking visits to the patients table.

About these practice questions

This DA0-002 question is part of Courseiva's 1,004-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 and reviewed by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

Last reviewed September 2026 · checked against the official CompTIA exam blueprint

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.