The Story That Explains the ER Model
A database designer works exactly the same way. Before creating a single table, she draws an Entity-Relationship Diagram — boxes for the "things" the business cares about, lines for how those things connect. The ER model is the blueprint of a database: cheap to draw, cheap to change, and impossible to skip if you want a clean design.
The Entity-Relationship (ER) Model is a high-level, conceptual data model introduced by Dr. Peter Chen in 1976. It describes what data an organisation needs to store and how the pieces relate — without yet worrying about how a specific DBMS will physically store it. Its visual form is the ER Diagram.
An ER diagram reads like a sentence. Entities are the nouns (Student, Course, Doctor), relationships are the verbs (enrols in, teaches, treats), and attributes are the adjectives that describe them (name, age, salary). If you can describe your business in plain English, you can already draw 80% of its ER diagram.
The Three Building Blocks
Every ER diagram, no matter how large, is assembled from just three core ingredients. Master these and everything else is detail.
The ER Notation Legend (Chen's Notation)
ER diagrams use a small, fixed vocabulary of shapes. The animated legend below introduces every symbol you will meet in this tutorial. Each shape carries a colour-coded border so it stays readable in both light and dark themes — watch them appear one by one.
Keep this legend handy — every later diagram reuses these exact symbols.
Entities and Entity Sets
Beginners constantly confuse an entity with an entity set. The distinction is simple but vital.
The dashed box is the set; each circle is one entity (one row). In the diagram we draw only the rectangle named STUDENT.
Entity Set = Table • Entity = Row • Attribute = Column. Whenever you read "STUDENT" in an ER diagram, think of an empty table with columns waiting to be filled.
Attributes and Their Types
Attributes describe entities, but not all attributes behave the same way. There are six important types, each with its own symbol. The animated diagram shows them all radiating from a single STUDENT entity.
Age is derived because it is computed from Date_of_Birth — it is never stored directly.
| Attribute Type | Symbol | Meaning | Example |
|---|---|---|---|
| Simple (Atomic) | Plain ellipse | Cannot be divided further | Gender, Age |
| Composite | Ellipse with sub-ellipses | Splits into smaller parts | Name → First + Last |
| Single-valued | Plain ellipse | Holds exactly one value | Date_of_Birth |
| Multivalued | Double ellipse | Holds many values | Phone_No, Email |
| Derived | Dashed ellipse | Computed from others | Age (from DOB) |
| Key | Underlined ellipse | Uniquely identifies entity | Roll_No |
More Examples — Each Type Across Real Entities
These six types show up in every database you will ever design. Below, each type is illustrated with several examples from different domains so the pattern becomes second nature.
- STUDENT: Gender, Age
- PRODUCT: Price, Colour
- EMPLOYEE: Salary, Designation
- STUDENT: Name → First + Last
- CUSTOMER: Address → Street + City + PIN
- EMPLOYEE: Date_of_Birth → Day + Month + Year
- PERSON: Date_of_Birth
- BOOK: ISBN
- ACCOUNT: Balance
- STUDENT: Phone_No, Email
- EMPLOYEE: Skills, Languages
- PERSON: Hobbies, Degrees
- PERSON: Age (from Date_of_Birth)
- ORDER: Total (Qty × Price)
- EMPLOYEE: Experience (today − Join_Date)
- STUDENT: Roll_No
- EMPLOYEE: Emp_ID
- PRODUCT: SKU
Worked Example — Breaking Down Composite Attributes
Composite attributes are the ones beginners most often get wrong. Here are three fully decomposed, showing exactly which leaf parts would become real columns.
Composite = one value split into parts (one Address = House + Street + City). Multivalued = many separate values of the same kind (two phone numbers, three email addresses). A single person has one composite Address but possibly several multivalued Phone_No entries.
A NULL value is a missing value, but a multivalued attribute is a single attribute holding several values at once. Students often write Phone_No as one normal ellipse — if a person can have a mobile and a landline, it must be a double ellipse.
Keys — Guaranteeing Uniqueness
Keys form a hierarchy. Every primary key is a candidate key; every candidate key is a super key — but not the other way around.
| Key Type | Definition | Example (STUDENT) |
|---|---|---|
| Super Key | Any set of attributes that uniquely identifies a row (may contain extras) | {Roll_No}, {Roll_No, Name}, {Roll_No, Age} |
| Candidate Key | A minimal super key — remove any attribute and uniqueness is lost | {Roll_No}, {Email}, {Aadhaar_No} |
| Primary Key | The one candidate key chosen by the designer to identify rows | Roll_No |
| Alternate Key | Candidate keys not chosen as primary | Email, Aadhaar_No |
| Composite Key | A key made of two or more attributes together | {Course_ID, Section} in ENROLLMENT |
| Foreign Key | An attribute that refers to the primary key of another table | Dept_ID inside STUDENT → DEPARTMENT |
Every primary key ⊆ candidate key ⊆ super key. The designer simply picks the best candidate as primary.
Relationships and Their Degree
A relationship is an association among entities; a relationship set is the collection of all such associations of the same type. The degree of a relationship is the number of entity sets it connects.
A relationship can have its own descriptive attributes too — e.g. ENROLS could carry a grade or enrol_date.
Participation Constraints
Where cardinality counts how many, participation answers a yes/no question: "Must every entity take part in this relationship?"
| Drawn with a single line |
| Some entities may not participate |
| Example: not every Employee manages a department |
| "It is optional" |
| Drawn with a double line |
| Every entity must participate |
| Example: every Loan must belong to a customer |
| "It is mandatory" |
Total participation is a business rule: a loan with no customer is meaningless, so the connection is mandatory.
Strong & Weak Entities
The Room is a weak entity: it has no key of its own and depends entirely on the Hotel (a strong entity) for identification. Delete the hotel and its rooms lose all meaning — they cannot exist on their own.
| Has its own primary key |
| Exists independently |
| Drawn as a single rectangle |
| Example: HOTEL, LOAN, EMPLOYEE |
| Has no key of its own |
| Depends on a strong "owner" entity |
| Drawn as a double rectangle |
| Example: ROOM, PAYMENT, DEPENDENT |
A weak entity is connected to its owner through an identifying relationship (a double diamond), and it is uniquely identified by combining its own partial key (dashed underline) with the owner's primary key.
Full identifier of a payment = Loan_No + Payment_No. Payment_No alone repeats across loans.
(1) It is drawn as a double rectangle; (2) it connects to its owner via a double diamond identifying relationship; (3) its key is a dashed-underlined partial key that only becomes unique when combined with the owner's primary key. A weak entity also always shows total participation in the identifying relationship.
Putting It All Together — A Mini University ER Diagram
Now we assemble every concept into one diagram. Watch it build up: entities first, then the relationship, then the connecting lines and attributes.
Reads as: "Many STUDENTs ENROL in many COURSEs, and each enrolment records a Grade." A textbook M:N relationship with a descriptive attribute.
From ER Diagram to Tables
An ER diagram is a plan; eventually it becomes real tables. The conversion follows a few mechanical rules. (This is conceptual mapping — no programming required.)
Applying rules 1 and 6 to our University diagram gives three tables:
-- Strong entities become their own tables
STUDENT ( Roll_No PK, Name, Gender )
COURSE ( Course_ID PK, Title )
-- M:N relationship becomes a junction table
ENROLS ( Roll_No FK, Course_ID FK, Grade )
-- Primary key = (Roll_No, Course_ID)
You can never store an M:N relationship in just two tables — there is nowhere to put the Grade. The junction table ENROLS solves this: one row per (student, course) pair, with the grade attached. This is one of the most common real-world schema patterns.
Common Mistakes to Avoid
"Purchase" sounds like a thing, but it is usually a relationship between Customer and Product, not an entity. Ask: does it have an independent identity, or does it only exist because two entities met?
An attribute ellipse without an underline is just data. Examiners deduct marks instantly when the key attribute is not underlined. Every strong entity needs exactly one underlined key.
Cardinality (1, N, M) answers "how many?"; participation (single vs double line) answers "is it mandatory?". They are independent — a relationship can be 1:N and total at the same time.
Quick Reference — Symbol Cheat Sheet
| Symbol | Represents | Remember By |
|---|---|---|
| Rectangle | Entity set | A solid "thing" |
| Double rectangle | Weak entity | Needs a partner to stand |
| Ellipse | Attribute | A descriptor |
| Underlined ellipse | Key attribute | The unique ID |
| Double ellipse | Multivalued attribute | Holds a list |
| Dashed ellipse | Derived attribute | Calculated, not stored |
| Diamond | Relationship set | The verb |
| Double diamond | Identifying relationship | Anchors a weak entity |
| Single line | Partial participation | Optional |
| Double line | Total participation | Mandatory |