Bird
0
0

You want to ensure that a birthdate column in a persons table only accepts dates in the past. Which constraint would best enforce this rule?

hard📝 Application Q15 of 15
SQL - Table Constraints
You want to ensure that a birthdate column in a persons table only accepts dates in the past. Which constraint would best enforce this rule?
AUNIQUE (birthdate)
BNOT NULL
CCHECK (birthdate < CURRENT_DATE)
DPRIMARY KEY (birthdate)
Step-by-Step Solution
Solution:
  1. Step 1: Identify constraint to limit date values

    To restrict birthdate to past dates, a CHECK constraint comparing birthdate to CURRENT_DATE is needed.
  2. Step 2: Evaluate options

    CHECK (birthdate < CURRENT_DATE) uses CHECK (birthdate < CURRENT_DATE), which enforces the rule. NOT NULL only requires a value, UNIQUE and PRIMARY KEY do not limit date range.
  3. Final Answer:

    CHECK (birthdate < CURRENT_DATE) -> Option C
  4. Quick Check:

    CHECK constraints enforce value rules [OK]
Quick Trick: Use CHECK with date comparison for valid date ranges [OK]
Common Mistakes:
MISTAKES
  • Using NOT NULL to enforce date range
  • Confusing UNIQUE or PRIMARY KEY with value limits
  • Not using CURRENT_DATE in CHECK

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes