Difficulty: Easy
Correct Answer: CHECK constraint
Explanation:
Introduction / Context:
To keep data valid at the source, SQL provides declarative constraints that the database enforces automatically. Choosing the right constraint ensures data integrity without application-side duplication.
Given Data / Assumptions:
Concept / Approach:
The CHECK constraint evaluates a Boolean expression per row. If the expression evaluates to true, the row is allowed; otherwise the statement fails. CHECK can reference one or more columns of the same row and supports ranges, sets, and simple predicates.
Step-by-Step Solution:
Verification / Alternative check:
Attempt to insert an invalid value; the database rejects it with a CHECK violation, proving the constraint works.
Why Other Options Are Wrong:
LIMIT / VALUE / FILTER constraint: Not standard SQL constraint names.
None of the above: Incorrect because CHECK is the standard mechanism.
Common Pitfalls:
Writing overly complex CHECK expressions can hurt readability; keep them clear and document business rules.
Final Answer:
CHECK constraint
Discussion & Comments