CMD Guide
HomeDatabasesER Models

Entities, Attributes, and Relationships

An ER model is built by reading a sentence of requirements and mechanically assigning each noun to one of three shapes — a thing you store rows about becomes a rectangle (entity), a fact about that thing becomes an ellipse (attribute), and a verb linking two things becomes a diamond (relationship) — so the diagram is just the requirements re-encoded into a form a database schema can be derived from.

The decision the diagram encodes

The shapes are not decoration; each one answers a different design question. When you are unsure which shape something is, ask the question the shape stands for:

The mechanism of ER modeling is applying these four questions to every noun and verb in the requirements, in order. Below is one end-to-end pass.

One worked build: a course-enrollment system

Start with a single sentence of real requirements and derive the whole model from it — no symbol is placed without a clause that justifies it.

"We need to track students — each has an ID, a name, a date of birth, a home address, and possibly several phone numbers. Students enroll in courses; each course has a code and a title. We sometimes need a student's age, and we report enrollments by city."

Walk the sentence noun by noun. The table is the trace: each row is one design decision and the exact clause that forced it.

#Phrase in requirementsQuestion askedDecisionSymbol
1"track students"Many independently-identified rows?Student is an entity setrectangle
2"each has an ID"Does it uniquely identify a row?StudentID is the keyunderlined ellipse
3"a name, a date of birth"Single fact about the student?Name, DOBplain ellipses
4"a home address"One value, or parts with meaning?Address decomposes into Street/City/State/Countrycomposite ellipse
5"possibly several phone numbers"One value or many per student?PhoneNumbers is multivalueddouble ellipse
6"sometimes need a student's age"Stored, or computed from another fact?Age = today − DOB, not storeddashed ellipse
7"courses; each has a code and title"Many identified rows?Course entity, key CourseCode, attr Titlerectangle
8"students enroll in courses"A verb linking two entities?EnrollsIn relationshipdiamond

Step 6 is the one beginners get wrong: "age" looks like an attribute, but storing it means re-writing every row every birthday and tolerating silently-stale data. Because it is a pure function of DOB, it is derived — drawn dashed and recomputed on read. Storing it is the classic redundancy bug normalization later tries to undo.

diagram
diagram

Type vs. set: the level you are drawing at

The diagram above is at the type level — it describes the shape of the data, not the data. Student the rectangle is an entity set (a type); the row (S101, Ada Lovelace, 1990-12-10) is one entity (an instance). The EnrollsIn diamond is a relationship type; the actual fact "S101 enrolls in CS50" is one element of its relationship set. You draw types once; the database holds thousands of instances of each. Mixing the two levels — drawing one specific student as a box — is a common early mistake that makes the diagram unmaintainable.

Type level (what you draw)Set / instance level (what the DB holds)
Student (entity set)S101 Ada, S102 Alan, S103 Grace …
EnrollsIn (relationship type)(S101,CS50), (S101,CS61), (S102,CS50) …

Pitfalls

Takeaways


Sources: Elmasri & Navathe, Fundamentals of Database Systems (7th ed., Ch. 3 — entity types, attribute classes, relationship types vs. sets); Silberschatz, Korth & Sudarshan, Database System Concepts (7th ed., Ch. 6, the E-R model and Chen notation); Peter Chen, "The Entity-Relationship Model" (ACM TODS, 1976), the original notation. Re-authored and deepened for this guide: reorganized from a symbol catalog into a single end-to-end derivation from one requirements sentence, with an explicit type-vs-set distinction and the derived-attribute redundancy pitfall corrected.

🎯 STANDOUT elevation: Why / example / when-not / failure / panel / drills — Entities, Attributes, and Relationships

Why this exists / the decision it encodes

ER modeling exists to force a decision per requirements phrase: what is independently stored (entity), what is a fact about one entity (attribute), and what is a verb between entities (relationship). That mapping is the contract for later relational tables — multivalued → child table, derived → compute on read, composite → split only to query grain.

Worked example with numbers or traced SQL/FD

Requirements: "students have ID, name, DOB, address, several phones; enroll in courses; need age"
Trace:
Student = entity (many identifiable rows); StudentID underlined key
Address composite → Street/City/... only if you filter by city
PhoneNumbers double-ellipse → later Phone(student_id, phone) table
Age dashed → not stored (today−DOB); storing age invents birthday update anomaly
EnrollsIn diamond; if grade/date needed → attributes on relationship (or Enrollment entity)
Type vs instance: draw Student once; DB holds (S101 Ada), (S102 Alan), …

When NOT / named alternative

Do not draw one rectangle per student instance. Do not store Age. Do not model a many-to-many as product_1/product_2 columns. Do not hang grade on Student (one grade for all courses). Skip exhaustive Chen ornaments in a 45-min LLD — rectangles + keys + cardinalities + relationship attributes are enough; full multivalued/derived notation is for schema design workshops.

Failure mode / ops fingerprint / interview trap

Failure: multivalued phones crammed as "555-1,555-2" — cannot index/join. Interview trap: confusing weak entity with "optional FK" without owner-identifying key. Ops: schema mirrors UI forms → every feature is a migration.

Domain judgment (K11 theory-bridge / K12 concurrency / K13 query-judgment)

K11: ER shapes encode the same integrity decisions normalization later formalizes with FDs. K13: attribute grain (City as own field) is an access-pattern judgment for future filters/indexes.

Hostile-panel drills (with model answers)

Q1. Why is Age derived, not stored?
Model answer: It is a pure function of DOB; storing it goes stale daily and invents mass update work. Derive on read unless a measured perf need forces a maintained cache with a refresh job.

Q2. Where does enrollment grade live?
Model answer: On the EnrollsIn relationship (or an Enrollment entity), never only on Student or Course — it is a fact about the pairing.

Q3. Multivalued phone → relational mapping?
Model answer: Double ellipse becomes its own table with FK to Student (and usually a composite key), not a comma-separated string column.

🤖 Don't fully get this? Learn it with Claude

Stuck on Entities, Attributes, and Relationships? Open Claude, copy a block below, and it'll teach you this exact concept — visually and interactively.

🎨 Explain it visually

Build the mental picture, not memorization.

I just read a lesson on **Entities, Attributes, and Relationships** (Databases) and want to truly understand it. Explain Entities, Attributes, and Relationships from first principles using ONE vivid real-world analogy and a visual mental model — draw it as ASCII art or a clear step-by-step diagram — with a concrete example using real numbers. Then ask me one question to check I got the mental picture, and wait for my reply. If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.
🤔 Walk me through it (interactive)

Socratic — adapts to where you're stuck.

Teach me **Entities, Attributes, and Relationships** interactively. Ask me ONE guiding question at a time, wait for my answer, and adapt to my confusion — build the idea with me step by step instead of explaining it all at once. If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.
🧪 Quiz me & fix my gaps

Active recall exposes what you missed.

Quiz me on **Entities, Attributes, and Relationships** with 5 questions, easy to tricky, ONE at a time. Tell me if each answer is right; at the end, explain clearly what I got wrong and why. If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.
🧠 Make it stick

Intuition + hook + flashcards for long-term memory.

Help me remember **Entities, Attributes, and Relationships** for the long term: give the one-sentence intuition, a memorable hook/mnemonic, a tiny worked example, and 3 active-recall flashcards (Q -> A). If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.

📝 My notes