On this page
Normalization & Data Modeling
Prev: design_patterns | Up: design_patterns | Next: Indexing & Storage Engines
Rel: DDL & Constraints, NoSQL Schema Design Patterns
Ref: PostgreSQL — Database Design
Tags: #public #databases #design-patterns #modeling
Contents
Normal Forms (1NF -> 3NF / BCNF)
- 1NF: Atomic column values (no comma-separated lists) and a unique primary key per row.
- 2NF: Every non-key column depends on the entire primary key (no partial dependencies on composite keys).
- 3NF / BCNF: Every non-key column depends on "the key, the whole key, and nothing but the key" (no transitive dependencies between non-key columns).
When to Denormalize
Normalize by default to eliminate update anomalies, then denormalize selectively only when profiling proves a join bottleneck:
- Store immutable historical snapshots (e.g.,
unit_price_at_purchaseonorder_items). - Maintain pre-aggregated counters or materialized views for read-heavy dashboards.
Common Relational Patterns
- Many-to-Many: Use an explicit junction table with a composite primary key
(post_id, tag_id). - Trees/Hierarchies: Adjacency list (
parent_id, queried withWITH RECURSIVE), materialized path (/1/4/9/), or closure table (ancestor_id, descendant_id, depth).
Linked from
Related notes
- tuts/databases/design_patterns Linked here; links to this page; shared tags: #databases
- tuts/databases/design_patterns/indexing_and_storage_engines Linked here; links to this page; shared tags: #databases
- tuts/databases/nosql/nosql_schema_design_patterns Linked here; links to this page; shared tags: #databases
- tuts/databases/sql/ddl_and_constraints Linked here; links to this page; shared tags: #databases
- tuts/databases/nosql/nosql_data_models links to this page; shared tags: #databases, #modeling
- tuts/databases shared tags: #databases
- tuts/databases/design_patterns/scaling_partitioning_and_sharding shared tags: #databases
- tuts/databases/design_patterns/schema_migrations_and_reliability shared tags: #databases
- tuts/databases/design_patterns/transactions_acid_and_isolation shared tags: #databases
- tuts/databases/mongodb shared tags: #databases