Skip to content
Home ยป Entity-Relationship (ER) Model in DBMS

Entity-Relationship (ER) Model in DBMS

1. Introduction to ER Model

The Entity-Relationship (ER) Model is a conceptual database model that represents real-world entities and their relationships. It helps in designing the database structure before implementation.

๐Ÿ”น Developed by: Peter Chen (1976)
๐Ÿ”น Purpose: Provides a high-level abstraction of database design.
๐Ÿ”น Used in: Database design phase to create a blueprint before converting to a relational schema.


2. Key Components of the ER Model

1๏ธโƒฃ Entities

An entity represents a real-world object that has a unique existence in the database.

๐Ÿ”น Types of Entities:

  • Strong Entity: Can exist independently (e.g., Student, Employee).
  • Weak Entity: Cannot exist without another entity (e.g., Order Item depends on Order).

๐Ÿ”น Example:

  • Student is an entity with attributes like Student_ID, Name, and Age.
  • Department is an entity with attributes like Department_ID and Department_Name.

2๏ธโƒฃ Attributes

Attributes represent properties of an entity.

๐Ÿ”น Types of Attributes:

  • Simple (Atomic): Cannot be divided further (e.g., Age, Name).
  • Composite: Can be divided (e.g., Full Name โ†’ First Name + Last Name).
  • Derived: Can be calculated from other attributes (e.g., Age from Date of Birth).
  • Multivalued: Can have multiple values (e.g., Phone Numbers).
  • Key Attribute: Uniquely identifies an entity (e.g., Student_ID).

๐Ÿ”น Example:
Entity: Student
Attributes: Student_ID (Primary Key), Name, Age, Phone Number, Address


3๏ธโƒฃ Relationships

A relationship defines how two or more entities are connected.

๐Ÿ”น Types of Relationships:

  • One-to-One (1:1): A student has one ID card, and each ID card belongs to one student.
  • One-to-Many (1:M): A department has many students, but a student belongs to one department.
  • Many-to-Many (M:N): A student can enroll in multiple courses, and a course can have multiple students.

๐Ÿ”น Example:
Relationship: Student ๐Ÿ“š — Enrolls In — ๐Ÿซ Course


3. ER Diagram Representation

An ER Diagram (ERD) visually represents entities, attributes, and relationships.

ER Diagram Symbols:

SymbolMeaning
Rectangle ๐ŸŸฆEntity
Ellipse ๐ŸตAttribute
Diamond ๐Ÿ”ทRelationship
Line โž–Connection
Double Ellipse โšชMultivalued Attribute
Dashed Ellipse ๐Ÿ”˜Derived Attribute
Double Rectangle ๐ŸŸซWeak Entity
Double Diamond ๐Ÿ”ท๐Ÿ”ทIdentifying Relationship

Example ER Diagram for Student-Course Relationship:

       +------------+           +-------------+  
| Student | | Course |
+------------+ +-------------+
| Student_ID |--- Enrolls In ---| Course_ID |
| Name | | Course_Name|
| Age | | Credits |
+------------+ +-------------+

๐Ÿ”น Student enrolls in Course (Many-to-Many Relationship).


4. Specialization in ER Model

1๏ธโƒฃ Generalization

  • Merging two or more entities into a higher-level entity.
  • Example: Car, Bike, Truck โ†’ generalized into Vehicle.

2๏ธโƒฃ Specialization

  • Dividing a higher-level entity into sub-entities.
  • Example: Employee โ†’ specialized into Manager, Developer, Intern.

3๏ธโƒฃ Aggregation

  • Relationship between a relationship and an entity.
  • Example: Project is assigned to Employee, and a Manager oversees the assignment.

5. Converting ER Model to Relational Model

Once an ER Model is designed, it must be converted into a Relational Model for database implementation.

๐Ÿ”น Steps for Conversion:

  1. Convert entities into tables.
  2. Convert attributes into table columns.
  3. Convert relationships into foreign keys or new tables (for M:N).

6. Advantages of the ER Model

โœ… Easy to Understand โ†’ Simple and graphical representation.
โœ… Conceptual Clarity โ†’ Clearly defines entities, attributes, and relationships.
โœ… Helps in Database Design โ†’ Used in the initial design phase before implementation.
โœ… Supports Complex Relationships โ†’ One-to-Many, Many-to-Many, Aggregation, etc.


7. Disadvantages of the ER Model

โŒ Not Suitable for Implementation โ†’ Needs conversion to a relational model first.
โŒ Cannot Represent All Constraints โ†’ Some business rules cannot be easily modeled.
โŒ Complex Diagrams โ†’ Large databases create cluttered ER diagrams.


8. Real-World Applications of ER Model

๐Ÿ“Œ University Database โ†’ Students, Courses, Instructors, Enrollment
๐Ÿ“Œ E-Commerce โ†’ Customers, Orders, Products, Payments
๐Ÿ“Œ Hospital Management โ†’ Patients, Doctors, Appointments, Treatments
๐Ÿ“Œ Banking System โ†’ Customers, Accounts, Transactions, Loans


9. Conclusion

The ER Model is a powerful conceptual tool for database design. It provides clear visualization of data and relationships before converting them into relational tables. Most modern DBMS (MySQL, Oracle, PostgreSQL) use ER modeling for efficient database structuring.