π― What is Entity Set?
An Entity Set is a collection of similar types of entities that share the same attributes.
In simple terms:
An Entity is one object.
An Entity Set is a group of such objects stored in the database.
π― Example:
Letβs take an example from a university database:
π€ Entity:
A single student | Student(ID: 101, Name: Swastika, Course: BSc)
π§βπ Entity Set:
All students in the college β for example:
Student(ID: 101, Name: Swastika, Course: BSc)
Student(ID: 102, Name: Aisha, Course: BTech)
Student(ID: 103, Name: Rahul, Course: BA)
π These form a Student Entity Set.
<div class="infographic-entity-set">
<style>
.infographic-entity-set {
--ink: #1a1a1a;
--ink-soft: #5c5c5c;
--paper: #ffffff;
--paper-alt: #f0ece4;
--accent: #2563eb;
--accent-soft:#e3ebfd;
--line: #ddd6c9;
--mono-font: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
background: var(--paper);
color: var(--ink);
padding: 2rem 1.5rem 2.5rem;
max-width: 760px;
margin: 0 auto;
box-sizing: border-box;
}
.infographic-entity-set[data-theme="dark"] {
--ink: #e8e6e1;
--ink-soft: #9a968c;
--paper: #121212;
--paper-alt: #1e1e26;
--accent: #5b8def;
--accent-soft:#202942;
--line: #2c313d;
}
.infographic-entity-set *, .infographic-entity-set *::before, .infographic-entity-set *::after {
box-sizing: border-box;
}
.infographic-entity-set h2 {
font-size: 1.4rem;
margin: 0 0 0.25rem;
letter-spacing: -0.01em;
}
.infographic-entity-set .subtitle {
color: var(--ink-soft);
font-size: 0.92rem;
margin: 0 0 1.5rem;
max-width: 52ch;
}
/* tabs */
.infographic-entity-set .tabs {
display: inline-flex;
background: var(--paper-alt);
border-radius: 999px;
padding: 4px;
margin-bottom: 1.25rem;
gap: 4px;
}
.infographic-entity-set .tab {
font: inherit;
font-size: 0.82rem;
font-weight: 600;
padding: 0.5rem 1rem;
border-radius: 999px;
border: none;
background: transparent;
color: var(--ink-soft);
cursor: pointer;
transition: background 0.2s ease, color 0.2s ease;
white-space: nowrap;
}
.infographic-entity-set .tab.is-active {
background: var(--accent);
color: #fff;
}
.infographic-entity-set .panel {
display: none;
}
.infographic-entity-set .panel.is-active {
display: block;
animation: entset-fade 0.3s ease;
}
@keyframes entset-fade {
from { opacity: 0; transform: translateY(4px); }
to { opacity: 1; transform: translateY(0); }
}
/* single entity card */
.infographic-entity-set .entity-card {
background: var(--paper-alt);
border-radius: 14px;
padding: 1.4rem;
max-width: 320px;
}
.infographic-entity-set .entity-card .kicker {
font-size: 0.68rem;
text-transform: uppercase;
letter-spacing: 0.08em;
color: var(--accent);
font-weight: 700;
margin-bottom: 0.6rem;
}
.infographic-entity-set .entity-card .avatar {
font-size: 2rem;
margin-bottom: 0.5rem;
display: block;
}
.infographic-entity-set .entity-field {
display: grid;
grid-template-columns: 34% 66%;
font-size: 0.85rem;
border-top: 1px solid var(--line);
padding: 0.5rem 0;
}
.infographic-entity-set .entity-field:first-of-type { border-top: none; margin-top: 0.4rem; }
.infographic-entity-set .entity-field .k {
color: var(--ink-soft);
font-family: var(--mono-font);
font-size: 0.76rem;
}
.infographic-entity-set .entity-field .v {
font-weight: 600;
}
.infographic-entity-set .entity-note {
margin-top: 0.9rem;
font-size: 0.78rem;
color: var(--ink-soft);
}
/* entity set table */
.infographic-entity-set .set-wrap {
background: var(--paper-alt);
border-radius: 14px;
padding: 1.1rem;
}
.infographic-entity-set .set-label {
font-size: 0.68rem;
text-transform: uppercase;
letter-spacing: 0.08em;
color: var(--accent);
font-weight: 700;
margin-bottom: 0.75rem;
}
.infographic-entity-set table {
width: 100%;
border-collapse: collapse;
font-size: 0.85rem;
background: var(--paper);
border-radius: 10px;
overflow: hidden;
}
.infographic-entity-set thead th {
text-align: left;
font-size: 0.7rem;
text-transform: uppercase;
letter-spacing: 0.05em;
color: var(--ink-soft);
padding: 0.5rem 0.7rem;
background: var(--paper-alt);
font-family: var(--mono-font);
}
.infographic-entity-set tbody td {
padding: 0.55rem 0.7rem;
border-top: 1px solid var(--line);
}
.infographic-entity-set tbody tr.is-origin td {
background: var(--accent-soft);
font-weight: 600;
}
.infographic-entity-set tbody tr.is-new {
animation: entset-row-in 0.4s ease;
}
@keyframes entset-row-in {
from { opacity: 0; transform: translateX(-6px); }
to { opacity: 1; transform: translateX(0); }
}
.infographic-entity-set .pin {
font-size: 0.7rem;
color: var(--accent);
margin-left: 0.35rem;
}
.infographic-entity-set .add-row {
margin-top: 1rem;
display: flex;
align-items: center;
gap: 0.7rem;
flex-wrap: wrap;
}
.infographic-entity-set .btn {
font: inherit;
font-size: 0.82rem;
font-weight: 600;
padding: 0.5rem 0.95rem;
border-radius: 999px;
border: 1px solid var(--line);
background: var(--paper);
color: var(--ink);
cursor: pointer;
transition: background 0.15s, border-color 0.15s, color 0.15s, opacity 0.2s;
}
.infographic-entity-set .btn:hover:not(:disabled) {
border-color: var(--accent);
color: var(--accent);
}
.infographic-entity-set .btn:disabled {
opacity: 0.4;
cursor: not-allowed;
}
.infographic-entity-set .count {
font-size: 0.78rem;
color: var(--ink-soft);
}
.infographic-entity-set .count strong {
color: var(--ink);
}
.infographic-entity-set .takeaway {
margin-top: 1.5rem;
font-size: 0.88rem;
color: var(--ink-soft);
border-left: 3px solid var(--accent);
padding: 0.5rem 0 0.5rem 0.9rem;
}
.infographic-entity-set .takeaway strong { color: var(--ink); }
@media (prefers-reduced-motion: reduce) {
.infographic-entity-set *, .infographic-entity-set *::before, .infographic-entity-set *::after {
animation-duration: 0.001ms !important;
transition-duration: 0.001ms !important;
}
}
</style>
<h2>Entity vs Entity Set</h2>
<p class="subtitle">One record, or the whole table of records like it? Flip between the two views below.</p>
<div class="tabs" role="tablist">
<button class="tab is-active" type="button" data-panel="single" role="tab">π€ Entity</button>
<button class="tab" type="button" data-panel="set" role="tab">π§βπ Entity Set</button>
</div>
<div class="panel is-active" id="panel-single">
<div class="entity-card">
<div class="kicker">Entity β a single instance</div>
<span class="avatar">π€</span>
<div class="entity-field"><span class="k">ID</span><span class="v">101</span></div>
<div class="entity-field"><span class="k">Name</span><span class="v">Swastika</span></div>
<div class="entity-field"><span class="k">Course</span><span class="v">BSc</span></div>
<div class="entity-note">Just one student. This is <strong>a</strong> Student β not the whole table.</div>
</div>
</div>
<div class="panel" id="panel-set">
<div class="set-wrap">
<div class="set-label">Entity Set β every Student in the college</div>
<table>
<thead>
<tr><th>ID</th><th>Name</th><th>Course</th></tr>
</thead>
<tbody id="set-body">
<tr class="is-origin"><td>101</td><td>Swastika<span class="pin">π same one from the Entity tab</span></td><td>BSc</td></tr>
<tr><td>102</td><td>Aisha</td><td>BTech</td></tr>
<tr><td>103</td><td>Rahul</td><td>BA</td></tr>
</tbody>
</table>
<div class="add-row">
<button class="btn" id="btn-add-student" type="button">β Enroll another student</button>
<span class="count">Set currently holds <strong id="set-count">3</strong> Student entities</span>
</div>
</div>
</div>
<p class="takeaway"><strong>Entity = one record.</strong> Entity Set = the full collection of every record of that same type β Swastika alone is an entity; all students together are the Student entity set.</p>
<script>
(function () {
var wrapper = document.currentScript.closest('.infographic-entity-set')
|| document.querySelector('.infographic-entity-set');
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 tabs = wrapper.querySelectorAll('.tab');
var panels = {
single: wrapper.querySelector('#panel-single'),
set: wrapper.querySelector('#panel-set')
};
tabs.forEach(function (tab) {
tab.addEventListener('click', function () {
tabs.forEach(function (t) { t.classList.remove('is-active'); });
tab.classList.add('is-active');
Object.keys(panels).forEach(function (key) {
panels[key].classList.toggle('is-active', key === tab.getAttribute('data-panel'));
});
});
});
var extraStudents = [
[104, 'Meera', 'BCom'],
[105, 'Karan', 'BSc'],
[106, 'Priya', 'BTech'],
[107, 'Farhan', 'BA'],
[108, 'Diya', 'BSc']
];
var pointer = 0;
var tbody = wrapper.querySelector('#set-body');
var addBtn = wrapper.querySelector('#btn-add-student');
var countEl = wrapper.querySelector('#set-count');
addBtn.addEventListener('click', function () {
if (pointer >= extraStudents.length) {
addBtn.disabled = true;
addBtn.textContent = 'Set is full for this demo';
return;
}
var s = extraStudents[pointer++];
var row = document.createElement('tr');
row.className = 'is-new';
row.innerHTML = '<td>' + s[0] + '</td><td>' + s[1] + '</td><td>' + s[2] + '</td>';
tbody.appendChild(row);
countEl.textContent = tbody.querySelectorAll('tr').length;
if (pointer >= extraStudents.length) {
addBtn.disabled = true;
addBtn.textContent = 'Set is full for this demo';
}
});
})();
</script>
</div>.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!');
});𧬠Types of Entity Sets:
πΉ Type | π§Ύ Description |
|---|---|
Strong Entity Set | Has a primary key and exists independently |
Weak Entity Set | Depends on a strong entity, lacks a complete primary key |
<div class="infographic-er-notation">
<style>
.infographic-er-notation {
--ink: #1a1a1a;
--ink-soft: #5c5c5c;
--paper: #ffffff;
--paper-alt: #f0ece4;
--accent: #2563eb;
--accent-soft:#e3ebfd;
--line: #ddd6c9;
--mono-font: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
background: var(--paper);
color: var(--ink);
padding: 2rem 1.5rem 2.5rem;
max-width: 820px;
margin: 0 auto;
box-sizing: border-box;
}
.infographic-er-notation[data-theme="dark"] {
--ink: #e8e6e1;
--ink-soft: #9a968c;
--paper: #121212;
--paper-alt: #1e1e26;
--accent: #5b8def;
--accent-soft:#202942;
--line: #2c313d;
}
.infographic-er-notation *, .infographic-er-notation *::before, .infographic-er-notation *::after {
box-sizing: border-box;
}
.infographic-er-notation h2 {
font-size: 1.4rem;
margin: 0 0 0.25rem;
letter-spacing: -0.01em;
}
.infographic-er-notation .subtitle {
color: var(--ink-soft);
font-size: 0.92rem;
margin: 0 0 1.5rem;
max-width: 54ch;
}
.infographic-er-notation .diagram-wrap {
background: var(--paper-alt);
border-radius: 14px;
padding: 1rem 0.75rem 0.5rem;
margin-bottom: 1.25rem;
}
.infographic-er-notation svg {
width: 100%;
height: auto;
display: block;
}
.infographic-er-notation .shape-rect,
.infographic-er-notation .shape-diamond,
.infographic-er-notation .shape-ellipse,
.infographic-er-notation .shape-dblellipse,
.infographic-er-notation .shape-dblrect {
fill: var(--paper);
stroke: var(--ink);
stroke-width: 2;
transition: opacity 0.3s ease, stroke 0.3s ease, stroke-width 0.3s ease;
}
.infographic-er-notation .shape-line {
stroke: var(--ink);
stroke-width: 1.6;
transition: opacity 0.3s ease, stroke 0.3s ease, stroke-width 0.3s ease;
}
.infographic-er-notation .diagram-label {
font-size: 12px;
font-weight: 600;
fill: var(--ink);
text-anchor: middle;
dominant-baseline: middle;
transition: opacity 0.3s ease;
}
.infographic-er-notation .er-elem.is-dim .shape-rect,
.infographic-er-notation .er-elem.is-dim .shape-diamond,
.infographic-er-notation .er-elem.is-dim .shape-ellipse,
.infographic-er-notation .er-elem.is-dim .shape-dblellipse,
.infographic-er-notation .er-elem.is-dim .shape-dblrect,
.infographic-er-notation .er-elem.is-dim .shape-line {
opacity: 0.25;
}
.infographic-er-notation .er-elem.is-dim .diagram-label {
opacity: 0.35;
}
.infographic-er-notation .er-elem.is-active .shape-rect,
.infographic-er-notation .er-elem.is-active .shape-diamond,
.infographic-er-notation .er-elem.is-active .shape-ellipse,
.infographic-er-notation .er-elem.is-active .shape-dblellipse,
.infographic-er-notation .er-elem.is-active .shape-dblrect {
stroke: var(--accent);
stroke-width: 3;
}
.infographic-er-notation .er-elem.is-active .shape-line {
stroke: var(--accent);
stroke-width: 2.6;
}
.infographic-er-notation .caption {
font-size: 0.82rem;
color: var(--ink-soft);
text-align: center;
padding: 0.6rem 0.5rem 0.9rem;
min-height: 2.4em;
}
.infographic-er-notation .caption strong { color: var(--accent); }
/* legend */
.infographic-er-notation .legend {
display: flex;
flex-direction: column;
border-radius: 12px;
overflow: hidden;
border: 1px solid var(--line);
}
.infographic-er-notation .legend-row {
display: grid;
grid-template-columns: 34% 22% 44%;
align-items: center;
gap: 0.5rem;
padding: 0.65rem 0.9rem;
background: var(--paper);
border-top: 1px solid var(--line);
cursor: pointer;
text-align: left;
font: inherit;
color: var(--ink);
transition: background 0.15s ease;
}
.infographic-er-notation .legend-row:first-child { border-top: none; }
.infographic-er-notation .legend-row:hover {
background: var(--accent-soft);
}
.infographic-er-notation .legend-row.is-active {
background: var(--accent-soft);
}
.infographic-er-notation .legend-row .figure {
font-weight: 700;
font-size: 0.85rem;
}
.infographic-er-notation .legend-row .symbol-icon svg {
width: 44px;
height: 26px;
display: block;
}
.infographic-er-notation .legend-row .symbol-icon svg .icon-shape {
fill: var(--paper);
stroke: var(--ink);
stroke-width: 2;
transition: stroke 0.2s ease;
}
.infographic-er-notation .legend-row.is-active .symbol-icon svg .icon-shape {
stroke: var(--accent);
}
.infographic-er-notation .legend-row .represents {
font-size: 0.78rem;
color: var(--ink-soft);
}
@media (max-width: 560px) {
.infographic-er-notation .legend-row {
grid-template-columns: 1fr;
gap: 0.25rem;
}
}
.infographic-er-notation .takeaway {
margin-top: 1.5rem;
font-size: 0.88rem;
color: var(--ink-soft);
border-left: 3px solid var(--accent);
padding: 0.5rem 0 0.5rem 0.9rem;
}
.infographic-er-notation .takeaway strong { color: var(--ink); }
@media (prefers-reduced-motion: reduce) {
.infographic-er-notation *, .infographic-er-notation *::before, .infographic-er-notation *::after {
animation-duration: 0.001ms !important;
transition-duration: 0.001ms !important;
}
}
</style>
<h2>ER Diagram Notation</h2>
<p class="subtitle">Every ER diagram is built from six shapes. Click a row below to see exactly where that shape shows up in a real diagram.</p>
<div class="diagram-wrap">
<svg viewBox="0 0 640 420" xmlns="http://www.w3.org/2000/svg">
<!-- connecting lines -->
<g class="er-elem" data-group="line">
<line class="shape-line" x1="150" y1="96" x2="222" y2="150"/>
<line class="shape-line" x1="300" y1="96" x2="278" y2="150"/>
<line class="shape-line" x1="310" y1="175" x2="320" y2="175"/>
<line class="shape-line" x1="410" y1="175" x2="440" y2="175"/>
<line class="shape-line" x1="250" y1="200" x2="250" y2="275"/>
<line class="shape-line" x1="250" y1="325" x2="250" y2="350"/>
</g>
<!-- Name: ellipse attribute -->
<g class="er-elem" data-group="ellipse">
<ellipse class="shape-ellipse" cx="150" cy="70" rx="55" ry="26"/>
<text class="diagram-label" x="150" y="70">Name</text>
</g>
<!-- Phone: double ellipse, multi-valued attribute -->
<g class="er-elem" data-group="dblellipse">
<ellipse class="shape-dblellipse" cx="300" cy="70" rx="55" ry="26"/>
<ellipse class="shape-dblellipse" cx="300" cy="70" rx="46" ry="18" fill="none"/>
<text class="diagram-label" x="300" y="70">Phone</text>
</g>
<!-- Student: entity rectangle -->
<g class="er-elem" data-group="rect">
<rect class="shape-rect" x="190" y="150" width="120" height="50" rx="2"/>
<text class="diagram-label" x="250" y="175">Student</text>
</g>
<!-- Course: entity rectangle -->
<g class="er-elem" data-group="rect">
<rect class="shape-rect" x="440" y="150" width="120" height="50" rx="2"/>
<text class="diagram-label" x="500" y="175">Course</text>
</g>
<!-- Enrolls: relationship diamond -->
<g class="er-elem" data-group="diamond">
<polygon class="shape-diamond" points="365,145 410,175 365,205 320,175"/>
<text class="diagram-label" x="365" y="175">Enrolls</text>
</g>
<!-- Has: relationship diamond -->
<g class="er-elem" data-group="diamond">
<polygon class="shape-diamond" points="250,275 290,300 250,325 210,300"/>
<text class="diagram-label" x="250" y="300">Has</text>
</g>
<!-- Dependent: weak entity, double rectangle -->
<g class="er-elem" data-group="dblrect">
<rect class="shape-dblrect" x="190" y="350" width="120" height="50" rx="2"/>
<rect class="shape-dblrect" x="197" y="357" width="106" height="36" rx="1" fill="none"/>
<text class="diagram-label" x="250" y="375">Dependent</text>
</g>
</svg>
<div class="caption" id="er-caption">Rectangles mark <strong>entities</strong> β Student and Course are both entities in this diagram.</div>
</div>
<div class="legend" role="group" aria-label="ER notation legend">
<button class="legend-row is-active" type="button" data-key="rect">
<span class="figure">Rectangle</span>
<span class="symbol-icon"><svg viewBox="0 0 44 26"><rect class="icon-shape" x="4" y="5" width="36" height="16"/></svg></span>
<span class="represents">Entities in ER Model</span>
</button>
<button class="legend-row" type="button" data-key="ellipse">
<span class="figure">Ellipse</span>
<span class="symbol-icon"><svg viewBox="0 0 44 26"><ellipse class="icon-shape" cx="22" cy="13" rx="18" ry="9"/></svg></span>
<span class="represents">Attributes in ER Model</span>
</button>
<button class="legend-row" type="button" data-key="diamond">
<span class="figure">Diamond</span>
<span class="symbol-icon"><svg viewBox="0 0 44 26"><polygon class="icon-shape" points="22,4 40,13 22,22 4,13"/></svg></span>
<span class="represents">Relationships among Entities</span>
</button>
<button class="legend-row" type="button" data-key="line">
<span class="figure">Line</span>
<span class="symbol-icon"><svg viewBox="0 0 44 26"><line class="icon-shape" x1="4" y1="13" x2="40" y2="13"/></svg></span>
<span class="represents">Attributes to Entities and Entity Sets with Other Relationship Types</span>
</button>
<button class="legend-row" type="button" data-key="dblellipse">
<span class="figure">Double Ellipse</span>
<span class="symbol-icon"><svg viewBox="0 0 44 26"><ellipse class="icon-shape" cx="22" cy="13" rx="18" ry="9"/><ellipse class="icon-shape" cx="22" cy="13" rx="12" ry="5" fill="none"/></svg></span>
<span class="represents">Multi-Valued Attributes</span>
</button>
<button class="legend-row" type="button" data-key="dblrect">
<span class="figure">Double Rectangle</span>
<span class="symbol-icon"><svg viewBox="0 0 44 26"><rect class="icon-shape" x="4" y="5" width="36" height="16"/><rect class="icon-shape" x="8" y="8" width="28" height="10" fill="none"/></svg></span>
<span class="represents">Weak Entity</span>
</button>
</div>
<p class="takeaway"><strong>Same six shapes, every diagram.</strong> Once you can spot a rectangle, ellipse, and diamond on sight, any ER diagram becomes readable.</p>
<script>
(function () {
var wrapper = document.currentScript.closest('.infographic-er-notation')
|| document.querySelector('.infographic-er-notation');
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 CAPTIONS = {
rect: 'Rectangles mark <strong>entities</strong> β Student and Course are both entities in this diagram.',
ellipse: 'Ellipses mark <strong>attributes</strong> β Name describes the Student entity, joined by a line.',
diamond: 'Diamonds mark <strong>relationships</strong> β Enrolls connects Student to Course, Has connects Student to Dependent.',
line: 'Lines mark the <strong>connections</strong> β every attribute and relationship ties back to an entity through a line.',
dblellipse: 'A double ellipse marks a <strong>multi-valued attribute</strong> β a Student can have more than one Phone number.',
dblrect: 'A double rectangle marks a <strong>weak entity</strong> β Dependent has no ID of its own and relies on Student.'
};
var rows = wrapper.querySelectorAll('.legend-row');
var elems = wrapper.querySelectorAll('.er-elem');
var caption = wrapper.querySelector('#er-caption');
function setActive(key) {
rows.forEach(function (r) {
r.classList.toggle('is-active', r.getAttribute('data-key') === key);
});
elems.forEach(function (el) {
var match = el.getAttribute('data-group') === key;
el.classList.toggle('is-active', match);
el.classList.toggle('is-dim', !match);
});
caption.innerHTML = CAPTIONS[key];
}
rows.forEach(function (row) {
row.addEventListener('click', function () {
setActive(row.getAttribute('data-key'));
});
});
setActive('rect');
})();
</script>
</div>.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!');
});β Key Points:
π¦ Entity = One object
π Entity Set = Collection of similar entities
π Strong Entity Set has its own key
π§· Weak Entity Set needs a foreign key