Database normalization

데이터 정규화

Move repeated facts into related tables to reduce inconsistent updates.

···
html
<div class="demo"><div class="head"><b>NORMALIZE</b><span id="mode">before</span></div><div class="stage norm"><div class="records"><div class="cell">#51 · Mina</div><div class="cell">#52 · Mina</div></div><div class="split">→</div><div class="records"><div class="cell">customer 7 · Mina</div><div class="cell">orders 51, 52 → 7</div></div></div><div class="foot"><span id="note">name copied twice</span><span>one source of truth</span></div></div>
css
*{box-sizing:border-box}.demo{width:min(96vw,820px);height:min(94vh,350px);padding:clamp(8px,2vmin,18px);border:1px solid var(--line);border-radius:14px;background:var(--surface);color:var(--fg);display:flex;flex-direction:column;gap:clamp(5px,1.5vmin,12px);font:600 clamp(12px,3.5vmin,15px)/1.25 var(--font-sans),sans-serif;overflow:hidden}.head,.foot,.row{display:flex;justify-content:space-between;align-items:center;gap:8px}.head b{color:var(--accent)}.head span,.foot,.muted{color:var(--muted)}.stage{flex:1;min-height:0;display:flex;align-items:center;justify-content:center;gap:8px}.cell,.pill{border:1px solid var(--line);border-radius:8px;background:var(--bg);padding:clamp(4px,1.2vmin,9px);text-align:center}.pill{border-radius:999px}.on{border-color:var(--accent)!important;background:color-mix(in srgb,var(--accent) 17%,var(--surface))!important;color:var(--fg)!important}.bad{border-color:#e16a5d!important;background:color-mix(in srgb,#e16a5d 18%,var(--surface))!important}.foot{font-size:clamp(12px,3vmin,14px)}.norm{justify-content:space-around}.records{display:grid;gap:5px;min-width:38%}.records .cell{padding:5px}.split{color:var(--accent);font-size:clamp(18px,6vmin,30px)}@media(max-width:400px){.norm{gap:3px}.records{min-width:42%}.records .cell{font-size:12px}}
js
let n=0;function tick(){document.querySelectorAll('.records').forEach((e,i)=>{e.style.opacity=i===n?'1':'.5';e.querySelectorAll('.cell').forEach(c=>c.classList.toggle('on',i===n))});document.getElementById('mode').textContent=n?'after':'before';document.getElementById('note').textContent=n?'customer updated once':'name copied twice';n=1-n}tick();const t=setInterval(tick,1200);document.querySelector('.demo').onclick=()=>{clearInterval(t);tick()}

Normalization separates different kinds of facts that were mixed into one table. If every order copies a customer address, changing that address means updating every order.

The demo turns repeated customer names into one customer row and references from orders. Too much splitting can require more joins, so weigh integrity against real query patterns.

When to use

Consider it when repeated values cause update or delete anomalies.

Open as page ↗