Database Constraint
Problem
Application code says:
An order must reference an existing customer.
But another application or bug writes directly to the database.
Now invalid data exists.
Solution — Database Constraints
Let the database enforce rules such as:
NOT NULL
UNIQUE
FOREIGN KEY
CHECK
Core idea: database constraints protect data invariants at the storage boundary itself.