ER Model in DBMS
In this lesson: ER model explained simply — entities, attributes, relationships, cardinality — with diagrams and examples for exams.
What is the ER model
The ER (Entity-Relationship) model is a way to plan a database before building it. You draw the real-world entities, their attributes, and the relationships between them. This diagram acts as a blueprint that you later turn into actual tables.
Entities
An entity is a real-world thing you store data about — a Student, a Book, an Order. In diagrams it is drawn as a rectangle. Each entity usually becomes a table, and each specific instance (one student) becomes a row.
Attributes
Attributes are the properties of an entity. A Student entity might have roll, name and marks. In diagrams they are ovals attached to the entity. When you build tables, attributes become columns.
- Key attribute — uniquely identifies the entity (like roll), underlined in diagrams.
- Composite attribute — made of parts (like a full address).
- Multivalued attribute — can have many values (like phone numbers).
Relationships
A relationship connects two entities. For example, a Student enrolls in a Course. In diagrams it is drawn as a diamond between the two entities. When turned into tables, relationships become foreign keys or a separate link table.
Cardinality
Cardinality tells you how many of one entity relate to another:
| Type | Meaning | Example |
|---|---|---|
| One-to-one | 1 relates to 1 | Person - Passport |
| One-to-many | 1 relates to many | Department - Students |
| Many-to-many | Many relate to many | Students - Courses |
Cardinality decides where foreign keys go, and whether you need a link table (for many-to-many).
From ER model to tables
- Each entity becomes a table.
- Each attribute becomes a column; the key attribute becomes the primary key.
- A one-to-many relationship adds a foreign key on the "many" side.
- A many-to-many relationship becomes a separate link table with two foreign keys.
This mapping is how a drawn ER diagram turns into a working relational database.
Common mistakes
- Confusing entity and attribute. Entity is the thing; attributes are its details.
- Missing the key attribute. Every entity needs one to become a primary key.
- Ignoring cardinality. It decides foreign keys and link tables.
- Forgetting many-to-many needs a link table. You cannot do it with a single foreign key.
Summary
- The ER model is a blueprint of entities, attributes and relationships.
- Entities are things (become tables); attributes are details (become columns).
- Relationships connect entities (become foreign keys or link tables).
- Cardinality is one-to-one, one-to-many, or many-to-many.
- An ER diagram maps directly onto relational tables.
Next, learn the drawing symbols in ER diagram symbols, or see full examples in ER diagram examples.
