Relational model

관계형 모델

Keys connect table rows so a query can combine the columns it needs.

···
html
<div class="demo"><div class="head"><b>JOIN ON customer_id</b><span id="pick">id 7</span></div><div class="stage join"><div class="table"><strong>orders</strong><div class="cell order">#51 → 7</div><div class="cell order">#52 → 9</div></div><div class="joinline" id="line">→</div><div class="table"><strong>customers</strong><div class="cell customer">7 · Mina</div><div class="cell customer">9 · Jun</div></div></div><div class="foot"><span id="result">#51 + Mina</span><span>matching keys</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)}.join{justify-content:space-around}.table{display:grid;gap:5px;min-width:36%;text-align:center}.table strong{color:var(--muted)}.joinline{font-size:clamp(18px,6vmin,30px);color:var(--accent)}
js
let n=0;function tick(){document.querySelectorAll('.order,.customer').forEach((e,i)=>e.classList.toggle('on',i%2===n));document.getElementById('pick').textContent='id '+(n?9:7);document.getElementById('result').textContent=n?'#52 + Jun':'#51 + Mina';n=1-n}tick();const t=setInterval(tick,1100);document.querySelector('.demo').onclick=()=>{clearInterval(t);tick()}

The relational model represents data as tables of rows and columns. Each row records a fact, and a key can refer to a row in another table.

In the demo, an order joins the customer whose id matches customer_id. Explicit relationships avoid copying customer names into every order, but a missing join condition can create unwanted combinations.

When to use

Use it when related business records need consistent storage and SQL queries.

Open as page ↗