π What is Data Model?
A Data Model is a conceptual framework that describes how data is organized, stored, and manipulated in a database.
Provides a way to describe the design of a DB at logical level.
Underlying the structure of the DB is the Data Model.
A collection of conceptual tools for describing data, data relationships, data semantics & consistency constraints.
E.g., ER model, Relational Model, object-oriented model, object-relational data model etc.
It defines the structure, relationships, and constraints of the data.
π Why Data Models Are Important
They help in designing the database.
Provide a way to visually and logically understand how data elements relate.
Support communication between developers, designers, and users.
<div class="infographic-datamodels" id="dmWrap">
<style>
.infographic-datamodels {
--ink: #1a1a1a;
--ink-soft: #5c5c5c;
--paper: #ffffff;
--paper-alt: #f6f3ee;
--accent: #2563eb;
--accent-soft:#e3ebfd;
--line: #ddd6c9;
--warn: #b45309;
--warn-soft: #fdf1e2;
background: var(--paper);
color: var(--ink);
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
padding: 2.5rem 1.5rem;
border-radius: 14px;
box-sizing: border-box;
max-width: 780px;
margin: 0 auto;
}
.infographic-datamodels[data-theme="dark"] {
--ink: #e8e6e1;
--ink-soft: #9a968c;
--paper: #121212;
--paper-alt: #1e1e26;
--accent: #5b8def;
--accent-soft:#202942;
--line: #2c313d;
--warn: #f0a95a;
--warn-soft: #3a2a1c;
}
.infographic-datamodels * { box-sizing: border-box; }
.dm-eyebrow {
font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase;
color: var(--accent); font-weight: 700; margin: 0 0 0.4rem; text-align: center;
}
.dm-title { font-size: 1.45rem; font-weight: 700; margin: 0 0 1.5rem; text-align: center; letter-spacing: -0.01em; }
.dm-tabs { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: center; margin-bottom: 1.5rem; }
.dm-tab {
font: inherit; font-size: 0.8rem; font-weight: 600;
background: var(--paper-alt); color: var(--ink); border: 1px solid var(--line);
border-radius: 999px; padding: 0.45rem 0.9rem; cursor: pointer;
transition: border-color .15s, background .15s, color .15s;
}
.dm-tab:hover { border-color: var(--accent); }
.dm-tab.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }
.dm-panel {
display: grid; grid-template-columns: 220px 1fr; gap: 1.5rem; align-items: center;
background: var(--paper-alt); border: 1px solid var(--line); border-radius: 12px;
padding: 1.5rem;
}
.dm-panel.is-fading { animation: dmFade .35s ease; }
@keyframes dmFade { from { opacity: 0.2; } to { opacity: 1; } }
.dm-diagram { display: flex; align-items: center; justify-content: center; }
.dm-diagram svg { display: block; max-width: 100%; }
.dm-panel-title { font-size: 1.1rem; font-weight: 700; margin: 0 0 0.2rem; color: var(--accent); }
.dm-panel-sub { font-size: 0.76rem; color: var(--ink-soft); margin: 0 0 0.7rem; }
.dm-panel-list { margin: 0 0 0.8rem; padding-left: 1.1rem; font-size: 0.86rem; line-height: 1.5; }
.dm-panel-list li { margin-bottom: 0.3rem; }
.dm-example-label {
font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em;
color: var(--ink-soft); font-weight: 700; margin: 0 0 0.25rem;
}
.dm-example-text { font-size: 0.85rem; line-height: 1.5; margin: 0 0 0.7rem; }
.dm-panel-text > *:last-child { margin-bottom: 0; }
.dm-limitation {
display: inline-flex; align-items: center; gap: 0.4rem;
background: var(--warn-soft); color: var(--warn); border-radius: 6px;
padding: 0.4rem 0.65rem; font-size: 0.78rem; font-weight: 600;
}
@media (max-width: 620px) {
.dm-panel { grid-template-columns: 1fr; text-align: center; }
.dm-panel-list { text-align: left; }
.dm-example-text, .dm-example-label { text-align: left; }
}
@media (prefers-reduced-motion: reduce) {
.infographic-datamodels *, .infographic-datamodels *::before, .infographic-datamodels *::after {
animation-duration: 0.001ms !important; transition-duration: 0.001ms !important;
}
}
</style>
<p class="dm-eyebrow">Database Fundamentals</p>
<h2 class="dm-title">Types of Data Models</h2>
<div class="dm-tabs" id="dmTabs"></div>
<div class="dm-panel" id="dmPanel"></div>
</div>
<script>
(function () {
var wrapper = document.getElementById('dmWrap');
// Dark mode detection β body attribute wins, then cookie, then light default
var bodyAttr = document.body.getAttribute('data-darkmode');
var dark;
if (bodyAttr === 'true') {
dark = true;
} else if (bodyAttr === 'false') {
dark = false;
} else {
var match = document.cookie.match(/(?:^|;\s*)darkMode=([^;]+)/);
dark = match ? match[1] === 'true' : false;
}
if (dark) wrapper.setAttribute('data-theme', 'dark');
var S = 'stroke:var(--accent)';
var SS = 'stroke:var(--ink-soft)';
var models = [
{
label: 'Hierarchical',
title: 'Hierarchical Data Model',
sub: 'Tree structure',
bullets: [
'Data is organized in a tree-like structure (parent-child).',
'Each child has only one parent.'
],
example: 'A file system directory structure.',
limitation: 'Poor flexibility for complex relationships.',
diagram:
'<svg width="150" height="110" viewBox="0 0 150 110">' +
'<circle cx="75" cy="18" r="14" fill="none" style="' + S + '" stroke-width="2.2"/>' +
'<circle cx="35" cy="80" r="14" fill="none" style="' + S + '" stroke-width="2.2"/>' +
'<circle cx="115" cy="80" r="14" fill="none" style="' + S + '" stroke-width="2.2"/>' +
'<path d="M75 32 L35 66 M75 32 L115 66" fill="none" style="' + SS + '" stroke-width="2"/>' +
'</svg>'
},
{
label: 'Network',
title: 'Network Data Model',
sub: 'Graph structure',
bullets: [
'Data is organized as a graph.',
'A child can have multiple parents.'
],
example: 'A college course system where students and courses connect many-to-many.',
limitation: null,
diagram:
'<svg width="150" height="110" viewBox="0 0 150 110">' +
'<circle cx="35" cy="18" r="14" fill="none" style="' + S + '" stroke-width="2.2"/>' +
'<circle cx="115" cy="18" r="14" fill="none" style="' + S + '" stroke-width="2.2"/>' +
'<circle cx="35" cy="90" r="14" fill="none" style="' + S + '" stroke-width="2.2"/>' +
'<circle cx="115" cy="90" r="14" fill="none" style="' + S + '" stroke-width="2.2"/>' +
'<path d="M35 32 L35 76 M35 32 L115 76 M115 32 L35 76 M115 32 L115 76" fill="none" style="' + SS + '" stroke-width="2"/>' +
'</svg>'
},
{
label: 'Relational',
title: 'Relational Data Model',
sub: 'Most common β tables of rows and columns',
bullets: [
'Data is organized in tables (relations) with rows and columns.',
'Uses keys and SQL to manage relationships and queries.'
],
example: 'A Student table and a Class table linked by a foreign key.',
limitation: null,
diagram:
'<svg width="170" height="100" viewBox="0 0 170 100">' +
'<rect x="5" y="15" width="65" height="55" rx="4" fill="none" style="' + S + '" stroke-width="2"/>' +
'<path d="M5 34 H70 M5 53 H70 M38 15 V70" fill="none" style="' + SS + '" stroke-width="1.4"/>' +
'<rect x="100" y="15" width="65" height="55" rx="4" fill="none" style="' + S + '" stroke-width="2"/>' +
'<path d="M100 34 H165 M100 53 H165 M133 15 V70" fill="none" style="' + SS + '" stroke-width="1.4"/>' +
'<path d="M70 42 H100" fill="none" style="' + SS + '" stroke-width="2" stroke-dasharray="4 3"/>' +
'</svg>'
},
{
label: 'Object-Oriented',
title: 'Object-Oriented Data Model',
sub: 'Objects, classes, inheritance',
bullets: [
'Data is represented as objects, like in object-oriented programming.',
'Supports inheritance, encapsulation, and polymorphism.'
],
example: 'Useful in complex applications like CAD and multimedia databases.',
limitation: null,
diagram:
'<svg width="140" height="110" viewBox="0 0 140 110">' +
'<rect x="35" y="8" width="70" height="30" rx="4" fill="none" style="' + S + '" stroke-width="2.2"/>' +
'<rect x="35" y="72" width="70" height="30" rx="4" fill="none" style="' + S + '" stroke-width="2.2"/>' +
'<path d="M70 38 L70 60 L58 72 M70 60 L82 72" fill="none" style="' + SS + '" stroke-width="2"/>' +
'</svg>'
},
{
label: 'Entity-Relationship',
title: 'Entity-Relationship (E-R) Model',
sub: 'Conceptual design model',
bullets: [
'A high-level conceptual model used in database design.',
'Represents data as entities, attributes, and relationships.'
],
example: 'A "Student" entity related to a "Course" entity through "EnrolledIn".',
limitation: null,
diagram:
'<svg width="200" height="80" viewBox="0 0 200 80">' +
'<rect x="5" y="25" width="60" height="30" rx="3" fill="none" style="' + S + '" stroke-width="2.2"/>' +
'<rect x="135" y="25" width="60" height="30" rx="3" fill="none" style="' + S + '" stroke-width="2.2"/>' +
'<path d="M100 20 L120 40 L100 60 L80 40 Z" fill="none" style="' + S + '" stroke-width="2.2"/>' +
'<path d="M65 40 H80 M120 40 H135" fill="none" style="' + SS + '" stroke-width="2"/>' +
'</svg>'
}
];
var tabs = document.getElementById('dmTabs');
var panel = document.getElementById('dmPanel');
var buttons = [];
function renderPanel(i) {
var m = models[i];
var html = '<div class="dm-diagram">' + m.diagram + '</div>';
html += '<div class="dm-panel-text">';
html += '<h3 class="dm-panel-title">' + m.title + '</h3>';
html += '<p class="dm-panel-sub">' + m.sub + '</p>';
html += '<ul class="dm-panel-list">';
m.bullets.forEach(function (b) { html += '<li>' + b + '</li>'; });
html += '</ul>';
html += '<p class="dm-example-label">Example</p>';
html += '<p class="dm-example-text">' + m.example + '</p>';
if (m.limitation) {
html += '<span class="dm-limitation">β ' + m.limitation + '</span>';
}
html += '</div>';
panel.innerHTML = html;
panel.classList.remove('is-fading');
void panel.offsetWidth;
panel.classList.add('is-fading');
}
models.forEach(function (m, i) {
var btn = document.createElement('button');
btn.type = 'button';
btn.className = 'dm-tab' + (i === 0 ? ' is-active' : '');
btn.textContent = m.label;
btn.addEventListener('click', function () {
buttons.forEach(function (b) { b.classList.remove('is-active'); });
btn.classList.add('is-active');
renderPanel(i);
});
tabs.appendChild(btn);
buttons.push(btn);
});
renderPanel(0);
})();
</script>.demo {
font-family: system-ui, sans-serif;
padding: 16px;
}
.demo h1 {
color: #2563eb;
margin: 0 0 8px;
}
.demo p {
color: #4b5563;
margin: 0;
}document.querySelector('.demo h1')?.addEventListener('click', () => {
alert('Hello from live preview!');
});π Comparison Table:
Data Model | Structure | Use Case |
|---|---|---|
Hierarchical | Tree (Parent-Child) | Simple hierarchical data |
Network | Graph | Complex many-to-many relationships |
Relational | Tables | Modern databases (e.g., MySQL) |
Object-Oriented | Objects | Complex data (e.g., multimedia) |
E-R Model | Entities/Relations | Database design (conceptual stage) |