This chapter covers the core features and capabilities of Data Modeling Patterns.
soft delete, partitioning, a full normalization walk-through, and a complete
worked e-commerce schema.
tree, and an FAQ, so you can choose correctly under time pressure.
entity-relationship diagram and design rationale that ties every pattern together.
All SQL is PostgreSQL syntax with notes where other engines differ. No external
dependencies — you need only a database to run it against (or just read it).
1. Unzip the product.
2. Skim this README, then open examples/ecommerce-er-diagram.md
for the big picture.
3. Run a pattern against a scratch database, e.g.:
psql "postgres://localhost/scratch" -f sql/normalization-examples.sql
psql "postgres://localhost/scratch" -f sql/scd-type2.sql
psql "postgres://localhost/scratch" -f examples/ecommerce-model.sqlEach file is self-contained: it creates its own schema, seeds demo data, and
ends with verification queries (commented) you can run to see the result.
4. Read the matching guide in docs/ for the *why* and the decision rules.
The SQL files create schemas named
dw,app,norm, andshop. Run them ona throwaway database so they never touch anything real.
Follow this guide to get Data Modeling Patterns up and running in your environment.
sql/ — runnable patterns| File | Pattern | What it teaches |
|---|---|---|
star-schema.sql | Star dimensional model | Fact + denormalized dimensions, grain, surrogate keys, a date dimension |
snowflake-schema.sql | Snowflake dimensional model | Normalized dimension hierarchies and when they earn their keep |
scd-type2.sql | Slowly Changing Dimension, Type 2 | Full history: validity windows, current flag, correct fact joins |
scd-type1-3.sql | SCD Types 1 & 3 | Overwrite vs keep-previous-value, chosen per column |
audit-columns.sql | Audit columns | created/updated bookkeeping, a tamper-proof trigger, full audit log |
soft-delete.sql | Soft delete | deleted_at marker, a safety-net view, partial unique indexes, purge job |
partitioning.sql | Table partitioning | RANGE / LIST / HASH strategies, pruning, instant retention |
normalization-examples.sql | Normalization | One messy table walked from unnormalized → 1NF → 2NF → 3NF |
docs/ — decision guides| File | Answers |
|---|---|
normalization-vs-denormalization.md | When to normalize, when to denormalize, and how to stay correct |
indexing-strategy.md | What to index, composite column order, why an index gets ignored |
scd-types.md | Which SCD type per attribute, and the Type 2 mechanics that trip people up |
star-vs-snowflake.md | Star vs snowflake, grain, and which to default to |
partitioning-guide.md | When partitioning actually helps (and when it just adds complexity) |
anti-patterns.md | 12 common schema mistakes and what to do instead |
examples/ — a complete worked model| File | Contents |
|---|---|
ecommerce-model.sql | A full e-commerce OLTP schema applying every pattern in context |
ecommerce-er-diagram.md | ER diagram, cardinalities, design rationale, access patterns |
Designing a new schema? Start with anti-patterns.md
(know what to avoid), then normalization-vs-denormalization.md
to set your target normal form, then build with
ecommerce-model.sql as a template.
Building a warehouse / reporting layer? Read
star-vs-snowflake.md, model with
star-schema.sql, and handle changing dimensions with
Performance problem on an existing schema? Go straight to
indexing-strategy.md, and consider
partitioning-guide.md if the table is large with a
date/lifecycle pattern.
Get the full Data Modeling Patterns and unlock everything.
Get the complete guide with every chapter unlocked, including code samples, diagrams, and best practices.
Access all interactive tools with complete data, all workload profiles, and the full scenario library.
Downloadable source code, configuration files, and working examples from every chapter.
Free updates for life. Every new chapter, tool, and improvement included.