43 lines
1.1 KiB
Markdown
43 lines
1.1 KiB
Markdown
# Data — First Principles
|
|
|
|
## 1. The Principles
|
|
|
|
### P1. Truth
|
|
The schema reflects the domain, not the application. If the data
|
|
model lies, every query lies.
|
|
|
|
### P2. Normalization Discipline
|
|
Duplication is a bug waiting to happen. The same fact lives in one
|
|
place.
|
|
|
|
### P3. Invariants in the Schema
|
|
Constraints live where the data lives. Application-layer checks are
|
|
defense, not enforcement.
|
|
|
|
### P4. Migration Safety
|
|
Schema changes are reversible, non-destructive, and tested. Production
|
|
data is sacred.
|
|
|
|
### P5. Indexing with Intent
|
|
Indexes exist for known query patterns. Every index earns its write
|
|
cost.
|
|
|
|
### P6. Naming Consistency
|
|
Same concept, same name, always. Across tables, columns, code, and
|
|
APIs.
|
|
|
|
### P7. Type Fidelity
|
|
Types match domain meaning. A `string` is rarely the right type for
|
|
an email, an ID, or a status.
|
|
|
|
### P8. Lifecycle Awareness
|
|
Data has a creation, a lifetime, and an end. Archival and deletion
|
|
are first-class.
|
|
|
|
### P9. Referential Integrity
|
|
Relationships are enforced, not assumed. Foreign keys exist. CASCADE
|
|
is intentional.
|
|
|
|
### P10. Performance Awareness
|
|
Schema choices have cost. Query plans are reviewed. Cardinality is
|
|
understood. |