Database Invariants
Every foreign key refers to an existing object. Every request has exactly
one request_id. created_at <= updated_at. These are sensors of
referential integrity — structural invariants that the database enforces.
Database invariants operate at a different level than runtime invariants: they’re checked by the database engine itself, not by querying the event stream. This gives them high oracle strength but limits them to properties the schema can express.
Sensor properties
| Property | Value |
|---|---|
| Oracle strength | High — constraint violation is definitive |
| Independence | High — database enforces, not the application |
| Scope | System-level |
| Feedback latency | Minutes |
| Actionability | Guiding — shows which constraint was violated |
| Type | Retrospective |
What it cannot detect
Only properties expressible as database constraints. Business rules (“a successful payment implies an order eventually becomes paid”) require runtime invariants checked against event streams.