import { motion } from 'motion/react'; export default function DenormalizationDiagram() { return (
DENORMALIZATION

Deliberate act of adding redundant data to speed up reads and simplify queries

{/* === HEADER BOX === */} {/* Database Icon */} {/* Text */} Denormalization is the deliberate act of adding redundant data to a previously normalized schema to speed up reads and simplify queries. It's a targeted performance optimization, not an excuse to skip good modelling. {/* === 1) NORMALIZED (Left) === */} {/* Title */} 1) NORMALIZED (SOURCE OF TRUTH) {/* Customers Icon */} {/* Customers Table */} customers {/* Header */} customer_id (PK) name (NOT NULL) tier (PK) {/* Data */} 1 Alice Gold 2 Bob Silver 3 Carol Bronze {/* Orders Icon */} {/* Orders Table */} orders {/* Header */} order_id (PK) customer_id (FK) order_total (NUMERIC(12,2)) created_at {/* Data */} 101 1 120.00 2025-05-01 10:15:00 102 2 85.50 2025-05-01 11:20:00 103 1 230.00 2025-05-02 09:30:00 104 3 75.00 2025-05-02 12:45:00 {/* Arrow between sections */} {/* === 2) TYPICAL REPORT (Bottom Left) === */} 2) TYPICAL REPORT NEEDS A JOIN SELECT c.name, c.tier, SUM(o.order_total) AS revenue FROM orders o JOIN customers c ON c.customer_id = o.customer_id GROUP BY c.name, c.tier; {/* === 3) DENORMALIZED (Right) === */} {/* Title */} 3) DENORMALIZED (FOR READ PERFORMANCE) {/* Subtitle */} orders_enriched (with redundant customer data) {/* Enriched Table */} {/* Header */} order_id (PK) customer_id (FK) customer_name (DENORMALIZED) customer_tier (DENORMALIZED) order_total (NUMERIC(12,2)) created_at {/* Data */} 101 1 Alice Gold 120.00 2025-05-01 10:15:00 102 2 Bob Silver 85.50 2025-05-01 11:20:00 103 1 Alice Gold 230.00 2025-05-02 09:30:00 104 3 Carol Bronze 75.00 2025-05-02 12:45:00 {/* Success message */} Now the same report is simpler and faster (no join needed): SELECT customer_name, customer_tier, SUM(order_total) AS revenue FROM orders_enriched GROUP BY customer_name, customer_tier; {/* SQL Source of Truth */} SQL: SOURCE OF TRUTH (NORMALIZED) -- Source of truth CREATE TABLE customers ( customer_id BIGINT PRIMARY KEY, name TEXT NOT NULL, {/* === PROS (Bottom Left) === */} PROS: WHAT YOU GAIN {/* Rocket Icon */} Faster reads sub-p99 latencies {/* Search Icon */} Simpler queries fewer joins/aggregations {/* === CONS (Bottom Center) === */} CONS: WHAT IT COSTS {/* Edit Icon */} Write amplification extra updates/inserts {/* Warning Icon */} ! Consistency risk stale/drifting data {/* === OPERATIONAL (Bottom Right) === */} {/* Gear Icon */} Operational overhead (refreshes, backfills, monitoring) {/* Fan-out Icon */} Change fan-out schema/logic updates must be mirrored {/* === EXAMPLE Badge === */} EXAMPLE
); }