๐What is ER Modeling?
ER Modeling in DBMS: Entity-Relationship (ER) Modeling is a high-level data modeling technique used to define the structure of a database visually. It represents entities (objects), their attributes (properties), and relationships (connections) between them in a graphical format.
Why Use ER Modeling?
โ
Helps in database design by visually structuring data
โ
Serves as a non-technical communication tool between developers and stakeholders
โ
Identifies relationships between entities, ensuring efficient database structure
โ
Simplifies conversion to relational database schemas
๐Key Concepts in ER Modeling
1. Entities
ER Modeling in DBMS: An entity is a real-world object or thing that can be uniquely identified.
๐น Example: An “Employee” in a company is an entity.
Characteristics of Entities:
- Each entity has unique properties (attributes)
- Attributes can have single or multiple values
- Entities are distinguishable from each other
Example:
A Programmer working at Microsoft can have the following attributes:
| Attribute | Value |
| Name | Peter |
| Age | 30 |
| Department | IT |
2. Attributes
ER Modeling in DBMS: Attributes define properties of an entity.
๐น Example: An Employee entity may have Name, Age, and Department as attributes.
Types of Attributes:
โ
ER Modeling in DBMS: Simple Attribute โ Cannot be divided further (e.g., Age, Name)
โ
Composite Attribute โ Can be divided into sub-parts (e.g., Full Name โ First Name, Last Name)
โ
Derived Attribute โ Can be computed from other attributes (e.g., Age derived from Date of Birth)
โ
Multivalued Attribute โ Can have multiple values (e.g., Phone Numbers)
Example of Multivalued Attribute:
| Employee ID | Name | Phone Numbers |
| 101 | John | 9876543210, 8765432109 |
3. Relationships in ER Modeling
ER Modeling in DBMS: Entities interact with each other through relationships.
Example: If each employee is assigned a computer, then both Employee and Computer are entities, and their association is a relationship.
Types of Relationships in DBMS
1๏ธโฃ One-to-One (1:1) โ One entity is associated with only one other entity.
๐น Example: A passport is assigned to only one person.
2๏ธโฃ One-to-Many (1:M) โ One entity is related to multiple entities.
๐น Example: A teacher can teach multiple students.
3๏ธโฃ Many-to-Many (M:N) โ Multiple entities are related to multiple entities.
๐น Example: A student can enroll in multiple courses, and each course can have multiple students.
๐Enhanced ER Model (EER)
ER Modeling in DBMS: The Enhanced Entity-Relationship (EER) Model is an advanced version of ER Modeling that supports more complex relationships and inherits features from object-oriented models.
Features of EER Model:
โ
Specialization โ Creating sub-entities from a parent entity (e.g., Employee โ Programmer, Manager)
โ
Generalization โ Merging multiple entities into one (e.g., Car and Bike into Vehicle)
โ
Aggregation โ A relationship between relationships
Example of Specialization:
General Entity: Employee
- Sub-Entities: Manager, Developer, Analyst
๐Case Study: ER Diagram for “MyFlix” Video Library
ER Modeling in DBMS: Letโs design an ER diagram for MyFlix Video Library, which rents out movies to members.
Step 1: Identify Entities
The main entities in MyFlix are:
๐ Members โ Stores member details
๐ Movies โ Stores movie details
๐ Categories โ Stores movie genres (e.g., Action, Drama)
๐ Movie Rentals โ Tracks which movies are rented out
๐ Payments โ Stores payment details of members
Step 2: Define Relationships Between Entities
ER Modeling in DBMS: Solution for Many-to-Many Relationship:
Since relational databases do not support many-to-many relationships, we introduce an intermediate table called MovieRentals that connects Members and Movies.
๐Creating an ER Model in MySQL Workbench
Steps to Create an ER Diagram in MySQL Workbench
1๏ธโฃ Open MySQL Workbench
2๏ธโฃ Click on โ+โ (Add Diagram)
3๏ธโฃ Double-click Add Diagram to open the workspace
4๏ธโฃ Drag Table Object to create entities
5๏ธโฃ Define attributes for each entity
6๏ธโฃ Use Place Relationship Tool to establish relationships
Example: Members Table Attributes
| Attribute Name | Data Type | Description |
| Membership Number | INT | Unique ID for members |
| Full Name | VARCHAR | Member’s full name |
| Gender | VARCHAR | Male / Female |
| Date of Birth | DATE | DOB of the member |
| Physical Address | VARCHAR | Residential address |
๐Final ER Diagram for MyFlix Video Library
ER Modeling in DBMS: After completing the steps, the ER Diagram should look like this:
Entities and Relationships:
Members (One-to-Many) Movie Rentals (Many-to-One) Movies
Movies (One-to-Many) Categories
Members (One-to-Many) Payments
Once the ER Model is ready, it can be converted into a relational schema for implementation in a database.
๐Summary of ER Modeling in DBMS
๐น ER Modeling is used for database design and visualization
๐น Entities represent real-world objects
๐น Attributes define entity properties
๐น Relationships connect entities
๐น EER Model extends ER by supporting specialization, generalization, and aggregation
๐น ER Diagrams can be easily created using MySQL Workbench
By using ER modeling, businesses can avoid poor database designs, minimize redundancy, and improve data consistency!
