> Term
database constraint
Strict, database-level rules that reject any data mutation violating the defined integrity of the schema.
Detailed Explanation
Database constraints are the ultimate line of defense for data integrity. They enforce conditions like uniqueness, non-nullability, foreign key relationships, and specific value checks at the storage level.
Relying purely on application-level validations is a known anti-pattern, as bugs, direct database edits, or bypass scripts will inevitably corrupt the data without strong database constraints.
Why It Matters
It guarantees that bad data cannot physically be written to the disk, protecting the system from application bugs and race conditions.
Common Failure Mode
Practical Example
Production Manifestation
Primary keys, foreign keys, `UNIQUE` indexes, `NOT NULL` constraints, and `CHECK` constraints.
Frequently Asked Questions
What is database constraint in short?
Strict, database-level rules that reject any data mutation violating the defined integrity of the schema.
What is the most common failure mode?
A developer removes a unique constraint to 'fix a migration error', resulting in thousands of duplicate user accounts during a race condition.
AI Summary
Strict, database-level rules that reject any data mutation violating the defined integrity of the schema. It guarantees that bad data cannot physically be written to the disk, protecting the system from application bugs and race conditions.
