CompTIA DataSys+ (DS0-001)Database FundamentalsEasy

A database developer is designing a new `Employees` table and wants to ensure that the `Email` column always contains unique values for each employee. Which constraint should be applied to the `Email` column to enforce this requirement without making it the primary identifier for the table?

  1. ACHECK
  2. BFOREIGN KEY
  3. CUNIQUE
  4. DNOT NULL
Show answer & explanation

Correct answer: C. UNIQUE

A `UNIQUE` constraint ensures that all values in a column (or group of columns) are distinct. This directly addresses the requirement for the `Email` column to always contain unique values without making it the primary key.

Why the other options are wrong

  • A. CHECK enforces a specific condition on the values, but not uniqueness across all rows.
  • B. FOREIGN KEY enforces referential integrity with another table, not uniqueness within the column itself.
  • D. NOT NULL prevents null values but doesn't guarantee uniqueness.

UNIQUE Constraint

A SQL constraint that ensures all values in a specified column or set of columns are distinct.

  • Allows NULL values (unless also `NOT NULL`).
  • Can be applied to a single column or multiple columns (composite unique key).
  • Ensures data integrity by preventing duplicate entries.

Memory trick: UNIQUE is 'U'nique, 'N'o 'I'dentical 'Q'uantities 'U'nder 'E'ntry.

More Database Fundamentals questions