Constraint
A rule that a database or file format enforces on a column, such as not blank, unique, or within a range. Data that breaks the rule is rejected.
A constraint stops bad values at the door, which is cheaper than finding them later. A spreadsheet or a plain text file enforces almost none, so the same rules have to be checked by validation instead.
Where it comes up
- Duplicate keys with conflicting valuesTwo rows share an identifier that should be unique, but disagree on other fields.
- Free text in a coded fieldA column meant to hold one of a few fixed values also holds comments, explanations, and whole sentences.
See also
- Business ruleA condition that data must meet because of how the organization works, not because of its format: a ship date cannot be earlier than its order date.
- ValidationChecking values against rules, such as a date being in the past or a state code being on the allowed list, and reporting what fails.
- SchemaThe declared structure of a dataset: its columns, their names and types, and the rules they must satisfy.