Courseiva
Data Concepts and EnvironmentseasyMultiple ChoiceObjective-mapped

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?

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 ensures that patient_id in visits references a valid patient_id in the patient table. Option A is wrong because a unique constraint prevents duplicate values but allows one NULL, and does not enforce referential integrity. Option C is wrong because a primary key ensures uniqueness and serves as the table's identifier, but it does not enforce relationships between tables. Option D is wrong because a check constraint validates values based on a condition, not referential integrity.

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 only ensures that patient_id values are unique, but it does not enforce referential integrity; it would not guarantee that each patient_id references a valid patient.

  • Foreign key

    Why this is correct

    A foreign key constraint ensures that patient_id in visits references a valid patient_id in the patient table.

  • Primary key

    Why it's wrong here

    A primary key would enforce uniqueness and non-null, but patient_id in visits is not unique (a patient can have multiple visits), and it does not enforce referential integrity.

  • Check constraint

    Why it's wrong here

    A check constraint validates values based on a condition, but it does not enforce referential integrity.

About these practice questions

This DA0-002 question is part of Courseiva's 986-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 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.