ER Model in DBMS
What is the ER Model?
The Entity-Relationship (ER) model is a high-level conceptual data model used to describe the structure of a database. It was proposed by Peter Chen in 1976. The ER model represents real-world objects as entities, their properties as attributes, and the connections between them as relationships.
ER diagrams are used during the database design phase to visualize the data structure before creating the actual database schema.
Entities and Attributes
An entity is a real-world object or concept that can be distinctly identified. Examples: Student, Employee, Product, Order.
An attribute is a property or characteristic of an entity. Types of attributes:
| Attribute Type | Description | Example |
|---|---|---|
| Simple (Atomic) | Cannot be divided further | Age, Gender |
| Composite | Can be divided into sub-parts | Name → (First, Last) |
| Multivalued | Can have multiple values | Phone numbers, Email addresses |
| Derived | Computed from other attributes | Age (from Date of Birth) |
| Key Attribute | Uniquely identifies an entity | Student_ID, Employee_ID |
| Null Attribute | May have no value | Middle name |
Relationships and Cardinality
A relationship describes how entities are associated with each other. The cardinality defines the number of entity instances that can participate in a relationship:
| Cardinality | Notation | Example |
|---|---|---|
| One-to-One (1:1) | 1 — 1 | Person has one Passport |
| One-to-Many (1:N) | 1 — N | Department has many Employees |
| Many-to-One (N:1) | N — 1 | Many Employees belong to one Department |
| Many-to-Many (M:N) | M — N | Students enroll in many Courses; Courses have many Students |
Participation Constraints
Participation constraints define whether all or some entity instances must participate in a relationship:
- Total Participation (Mandatory): Every entity instance MUST participate in the relationship. Represented by a double line in ER diagrams. Example: Every Employee MUST work for a Department.
- Partial Participation (Optional): Some entity instances may not participate. Represented by a single line. Example: Some Employees may not manage a Department.
Weak Entities
A weak entity is an entity that cannot be uniquely identified by its own attributes alone — it depends on a strong (owner) entity for its identification. Weak entities:
- Do not have a primary key of their own
- Have a partial key (discriminator) that identifies them within the context of the owner entity
- Have a total participation in the identifying relationship
- Represented by a double rectangle in ER diagrams
Example: An Order_Item entity is weak — it depends on the Order entity. An item number (1, 2, 3...) only makes sense within a specific order.
ER Diagram Notation Summary
| Symbol | Represents |
|---|---|
| Rectangle | Entity |
| Double Rectangle | Weak Entity |
| Ellipse | Attribute |
| Double Ellipse | Multivalued Attribute |
| Dashed Ellipse | Derived Attribute |
| Underlined Attribute | Key Attribute (Primary Key) |
| Diamond | Relationship |
| Double Diamond | Identifying Relationship (for weak entity) |
| Single Line | Partial Participation |
| Double Line | Total Participation |
| 1, N, M | Cardinality ratios |
Example: University ER Model
Consider a university database with the following entities and relationships:
- STUDENT (Student_ID, Name, DOB, Email) — Key: Student_ID
- COURSE (Course_ID, Title, Credits) — Key: Course_ID
- INSTRUCTOR (Instructor_ID, Name, Department) — Key: Instructor_ID
- DEPARTMENT (Dept_ID, Dept_Name, Location) — Key: Dept_ID
Relationships:
- ENROLLS: Student M:N Course (with attribute: Grade, Semester)
- TEACHES: Instructor 1:N Course
- BELONGS_TO: Instructor N:1 Department
- OFFERS: Department 1:N Course
Ready to Level Up Your Skills?
Explore 500+ free tutorials across 20+ languages and frameworks.