ERD Fundamentals
Before tables, there is a domain. An ERD is the bridge between a real-world problem and a relational schema.
In plain English
An ERD is a simple sketch of the things you care about and the facts you need to remember about them.
The one idea
An ERD is a contract sketch: entities are nouns, relationships are verbs, and attributes are the facts you must remember.
Most schema bugs are modeling bugs that were visible in the diagram. Drawing the relationship before the tables exposes ambiguous business rules early.
By the end
- 01Identify entities, attributes, and keys in a domain.
- 02Distinguish simple, composite, multivalued, and derived attributes.
- 03Know what makes an entity strong or weak.
- 04Read basic ERD notation.
Entities and attributes
An entity is a distinguishable object or concept, such as a Student or a Course. An entity set is the collection of all such objects. An attribute describes an entity. A simple attribute is atomic; a composite attribute has parts, such as an address with street, city, and postal code. A multivalued attribute can have several values, such as phone numbers. A derived attribute is computed, such as age from a birth date.
Student
id simple, key
name composite (first, last)
phone multivalued
birth_date stored
age derived from birth_dateKeys and strong entities
A key uniquely identifies an entity within its set. A strong entity has its own key, such as student_id. A weak entity cannot be uniquely identified without the owner entity; its key includes the owner's key. In an ERD, entities are rectangles, attributes are ovals, keys are underlined, and weak entities use a double rectangle.
From ERD to tables
A strong entity usually becomes a table with its attributes as columns and its key as the primary key. Composite attributes are flattened into separate columns. Multivalued attributes become separate tables with a foreign key back to the entity. Derived attributes are usually not stored.
A library loan is not a book
A library wants to record who borrowed which book and when it is due.
Draw Member and Book as entities and Borrow as a relationship.
The diagram says a member borrows a book.
Add borrowed_on and due_on to Borrow.
The relationship now carries facts that belong to the event, not to the book.
Allow the same member to borrow the same book again later.
Borrow becomes its own entity, Loan, with a loan_id and a history.
ConclusionA relationship with attributes is often an entity in disguise. The ERD lets you see that before a table forces the issue.
Instrument
Watch it happen.
Step through one operation at a time
Identify the entities
The domain has two strong entities: Student and Course. Each has an independent key.
The trade-off
No free correctness.
Gain
A shared picture of the domain that non-programmers can review.
Cost
A diagram can become too detailed to read, and it is not automatically a good physical schema.
Verdict
Keep the conceptual diagram readable; move implementation details into the relational design.
Recap
What to keep.
Takeaways
- +An entity is an object; an entity set is a collection of objects.
- +Attributes describe entities and can be simple, composite, multivalued, or derived.
- +A strong entity has its own key; a weak entity depends on an owner.
- +Multivalued attributes usually become separate tables.
- +ERD notation maps naturally to relational tables.
Traps
- !Treating an attribute as an entity when it has its own identity.
- !Storing a derived value and then forgetting to update it.
- !Giving a weak entity its own independent primary key.
Focus
- →Identify entities and keys in a short domain description.
- →Classify attributes correctly.
- →Explain how a multivalued attribute becomes a table.
Check yourself
Before you turn the page.
What is a derived attribute?
What makes a weak entity weak?