MySQL + SQL · Lesson 21
ER Model and ER Diagram
What is the ER Model?
The Entity-Relationship (ER) model is a way to visually design a database before creating tables. It shows entities, their attributes, and the relationships between them.
Building Blocks
| Element | Meaning | Example |
|---|---|---|
| Entity | A real-world object (becomes a table) | Student, Teacher |
| Attribute | A property of an entity (becomes a column) | name, age |
| Relationship | A link between entities | Student studies Course |
| Key attribute | Uniquely identifies an entity | roll_no |
Relationship Types
- One-to-One (1:1): one student has one ID card.
- One-to-Many (1:N): one class has many students.
- Many-to-Many (M:N): students enroll in many courses.
Summary
- ER model = visual database design.
- Entity→table, attribute→column, relationship→link.
- Relationships: 1:1, 1:N, M:N.