π§βπ What is an attribute?
An attribute is a property or characteristic that describes an entity.
In simple terms:
An Entity is like a noun (e.g., Student).
An Attribute is like an adjective β it tells more about the entity (e.g., name, age, roll number).
π§βπ Example:
For the Student entity, common attributes could be:
π
Student_IDπ§
Nameπ’
Ageπ
Course
Each row in a table will have different values for these attributes.
<div class="infographic-attribute-types">
<style>
.infographic-attribute-types {
--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-attribute-types[data-theme="dark"] {
--ink: #e8e6e1;
--ink-soft: #9a968c;
--paper: #121212;
--paper-alt: #1e1e26;
--accent: #5b8def;
--accent-soft:#202942;
--line: #2c313d;
}
.infographic-attribute-types *, .infographic-attribute-types *::before, .infographic-attribute-types *::after {
box-sizing: border-box;
}
.infographic-attribute-types h2 {
font-size: 1.4rem;
margin: 0 0 0.25rem;
letter-spacing: -0.01em;
}
.infographic-attribute-types .subtitle {
color: var(--ink-soft);
font-size: 0.92rem;
margin: 0 0 1.5rem;
max-width: 56ch;
}
/* entity card */
.infographic-attribute-types .entity-card {
background: var(--paper-alt);
border-radius: 14px;
padding: 1rem;
margin-bottom: 1.25rem;
}
.infographic-attribute-types .entity-kicker {
font-size: 0.68rem;
text-transform: uppercase;
letter-spacing: 0.08em;
color: var(--accent);
font-weight: 700;
margin-bottom: 0.6rem;
padding-left: 0.2rem;
}
.infographic-attribute-types .field-row {
background: var(--paper);
border-radius: 10px;
padding: 0.65rem 0.85rem;
margin-bottom: 6px;
border: 1.5px solid transparent;
transition: border-color 0.3s ease, box-shadow 0.3s ease;
}
.infographic-attribute-types .field-row:last-child { margin-bottom: 0; }
.infographic-attribute-types .field-row.is-glow {
border-color: var(--accent);
box-shadow: 0 0 0 3px var(--accent-soft);
}
.infographic-attribute-types .field-main {
display: flex;
align-items: center;
gap: 0.6rem;
}
.infographic-attribute-types .f-label {
font-family: var(--mono-font);
font-size: 0.76rem;
color: var(--ink-soft);
min-width: 130px;
}
.infographic-attribute-types .f-value {
font-weight: 600;
font-size: 0.88rem;
flex: 1;
}
.infographic-attribute-types .f-badge {
font-size: 0.68rem;
font-weight: 700;
color: var(--accent);
background: var(--accent-soft);
border-radius: 999px;
padding: 0.15rem 0.55rem;
opacity: 0;
transform: scale(0.8);
transition: opacity 0.25s ease, transform 0.25s ease;
white-space: nowrap;
}
.infographic-attribute-types .f-badge.is-visible {
opacity: 1;
transform: scale(1);
}
.infographic-attribute-types .field-extra {
max-height: 0;
overflow: hidden;
transition: max-height 0.35s ease;
}
.infographic-attribute-types .field-extra.is-open {
max-height: 100px;
margin-top: 0.55rem;
}
.infographic-attribute-types .chip-row {
display: flex;
flex-wrap: wrap;
gap: 0.4rem;
padding-left: calc(130px + 0.6rem);
}
@media (max-width: 520px) {
.infographic-attribute-types .chip-row { padding-left: 0; }
.infographic-attribute-types .f-label { min-width: 100px; }
}
.infographic-attribute-types .chip {
font-family: var(--mono-font);
font-size: 0.76rem;
background: var(--accent-soft);
color: var(--accent);
padding: 0.25rem 0.6rem;
border-radius: 6px;
opacity: 0;
transform: translateY(-3px);
animation: attr-chip-in 0.3s ease forwards;
}
@keyframes attr-chip-in {
to { opacity: 1; transform: translateY(0); }
}
.infographic-attribute-types .derive-note {
font-family: var(--mono-font);
font-size: 0.76rem;
color: var(--accent);
padding-left: calc(130px + 0.6rem);
opacity: 0;
animation: attr-chip-in 0.3s ease forwards;
}
@media (max-width: 520px) {
.infographic-attribute-types .derive-note { padding-left: 0; }
}
/* type selector grid */
.infographic-attribute-types .type-grid {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 8px;
}
@media (max-width: 560px) {
.infographic-attribute-types .type-grid { grid-template-columns: 1fr; }
}
.infographic-attribute-types .type-btn {
text-align: left;
font: inherit;
background: var(--paper);
border: 1px solid var(--line);
border-radius: 10px;
padding: 0.6rem 0.8rem;
cursor: pointer;
color: var(--ink);
transition: border-color 0.15s ease, background 0.15s ease;
}
.infographic-attribute-types .type-btn:hover {
border-color: var(--accent);
}
.infographic-attribute-types .type-btn.is-active {
border-color: var(--accent);
background: var(--accent-soft);
}
.infographic-attribute-types .type-btn .t-name {
font-weight: 700;
font-size: 0.85rem;
display: block;
margin-bottom: 0.1rem;
}
.infographic-attribute-types .type-btn .t-desc {
font-size: 0.75rem;
color: var(--ink-soft);
display: block;
}
.infographic-attribute-types .caption {
font-size: 0.82rem;
color: var(--ink-soft);
text-align: center;
margin: 1rem 0 0;
min-height: 2.2em;
}
.infographic-attribute-types .caption strong { color: var(--accent); }
.infographic-attribute-types .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-attribute-types .takeaway strong { color: var(--ink); }
@media (prefers-reduced-motion: reduce) {
.infographic-attribute-types *, .infographic-attribute-types *::before, .infographic-attribute-types *::after {
animation-duration: 0.001ms !important;
transition-duration: 0.001ms !important;
}
}
</style>
<h2>βοΈ Types of Attributes</h2>
<p class="subtitle">Six labels, one Student. Click a type below and watch it play out live on the entity above.</p>
<div class="entity-card">
<div class="entity-kicker">Student entity</div>
<div class="field-row" data-field="student_id">
<div class="field-main">
<span class="f-label">Student_ID</span>
<span class="f-value">2041</span>
<span class="f-badge" id="badge-student_id">π KEY</span>
</div>
</div>
<div class="field-row" data-field="roll_no">
<div class="field-main">
<span class="f-label">Roll_No</span>
<span class="f-value">14</span>
</div>
</div>
<div class="field-row" data-field="name">
<div class="field-main">
<span class="f-label">Name</span>
<span class="f-value">Swastika Rao</span>
</div>
<div class="field-extra" id="extra-name">
<div class="chip-row">
<span class="chip" style="animation-delay:0.05s">First_Name: Swastika</span>
<span class="chip" style="animation-delay:0.15s">Last_Name: Rao</span>
</div>
</div>
</div>
<div class="field-row" data-field="dob">
<div class="field-main">
<span class="f-label">Date_of_Birth</span>
<span class="f-value">12 Mar 2005</span>
</div>
</div>
<div class="field-row" data-field="age">
<div class="field-main">
<span class="f-label">Age</span>
<span class="f-value">21</span>
</div>
<div class="field-extra" id="extra-age">
<div class="derive-note">β calculated from Date_of_Birth, not stored directly</div>
</div>
</div>
<div class="field-row" data-field="phone">
<div class="field-main">
<span class="f-label">Phone_Numbers</span>
<span class="f-value">2 numbers on file</span>
</div>
<div class="field-extra" id="extra-phone">
<div class="chip-row">
<span class="chip" style="animation-delay:0.05s">+91 98765 43210</span>
<span class="chip" style="animation-delay:0.15s">+91 91234 56780</span>
</div>
</div>
</div>
</div>
<div class="type-grid">
<button class="type-btn is-active" type="button" data-key="simple">
<span class="t-name">Simple Attribute</span>
<span class="t-desc">Cannot be broken down further</span>
</button>
<button class="type-btn" type="button" data-key="composite">
<span class="t-name">Composite Attribute</span>
<span class="t-desc">Can be divided into sub-parts</span>
</button>
<button class="type-btn" type="button" data-key="derived">
<span class="t-name">Derived Attribute</span>
<span class="t-desc">Can be calculated from other attributes</span>
</button>
<button class="type-btn" type="button" data-key="multivalued">
<span class="t-name">Multi-valued Attribute</span>
<span class="t-desc">Can hold multiple values</span>
</button>
<button class="type-btn" type="button" data-key="singlevalued">
<span class="t-name">Single-valued Attribute</span>
<span class="t-desc">Holds only one value per instance</span>
</button>
<button class="type-btn" type="button" data-key="key">
<span class="t-name">Key Attribute</span>
<span class="t-desc">Uniquely identifies an entity</span>
</button>
</div>
<script>
(function () {
var wrapper = document.currentScript.closest('.infographic-attribute-types')
|| document.querySelector('.infographic-attribute-types');
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 TYPES = {
simple: { match: ['roll_no'], caption: '<strong>Roll_No</strong> is Simple β it\'s already atomic. There\'s nothing left to divide.' },
composite: { match: ['name'], extra: 'name', caption: '<strong>Name</strong> is Composite β it splits cleanly into First_Name and Last_Name.' },
derived: { match: ['dob', 'age'], extra: 'age', caption: '<strong>Age</strong> is Derived β it\'s computed from Date_of_Birth, not stored on its own.' },
multivalued: { match: ['phone'], extra: 'phone', caption: '<strong>Phone_Numbers</strong> is Multi-valued β one Student can have more than one on file.' },
singlevalued: { match: ['roll_no', 'dob'], caption: '<strong>Roll_No</strong> and <strong>Date_of_Birth</strong> are Single-valued β exactly one value per student, always.' },
key: { match: ['student_id'], badge: 'student_id', caption: '<strong>Student_ID</strong> is the Key Attribute β it uniquely identifies this Student. No two students share one.' }
};
var rows = wrapper.querySelectorAll('.field-row');
var typeBtns = wrapper.querySelectorAll('.type-btn');
var caption = wrapper.querySelector('#attr-caption');
var badgeStudentId = wrapper.querySelector('#badge-student_id');
function resetChips(el) {
// restart chip stagger animation each time it opens
var chips = el.querySelectorAll('.chip, .derive-note');
chips.forEach(function (c) {
c.style.animation = 'none';
void c.offsetWidth;
c.style.animation = '';
});
}
function applyType(key) {
var t = TYPES[key];
rows.forEach(function (row) {
var f = row.getAttribute('data-field');
row.classList.toggle('is-glow', t.match.indexOf(f) !== -1);
var extra = row.querySelector('.field-extra');
if (extra) {
var shouldOpen = t.extra === f;
extra.classList.toggle('is-open', shouldOpen);
if (shouldOpen) resetChips(extra);
}
});
badgeStudentId.classList.toggle('is-visible', t.badge === 'student_id');
typeBtns.forEach(function (b) {
b.classList.toggle('is-active', b.getAttribute('data-key') === key);
});
caption.innerHTML = t.caption;
}
typeBtns.forEach(function (btn) {
btn.addEventListener('click', function () {
applyType(btn.getAttribute('data-key'));
});
});
applyType('simple');
})();
</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!');
});π§ Summary:
π§± Term | π Meaning |
|---|---|
Entity | Real-world object or thing |
Attribute | Descriptive property of an entity |
Entity Set | Collection of similar entities |