Check Constraint
PronunciationCHEK kun-STRAYNT
Definition
A check constraint is a rule stored in the database that every row must satisfy, such as "the amount must be greater than zero". The database rejects any row that breaks it.
Where you hear it
In schema design, migrations, and discussions about where validation should live.
Examples
A check constraint stops anyone saving a negative amount, even from a script.
Add a check constraint so weeks can never be zero.
The check constraint rejects any order whose quantity is zero.
Common mistake
Validating only in application code. Another script, a manual edit or a future service can bypass it; the database cannot be bypassed.
Don't confuse with
Application validation, which gives friendly messages but can be skipped. The constraint is the last line of defence.
Say it at work
- In a meeting or chat
Put the rule in a check constraint, not just in the form.
- In an email or ticket
The insert failed on the check constraint.