In this article Entity Relationship Model we give the information about The Entity-Relationship (ER) model is a high-level conceptual data model that defines the data elements and their relationships in a system.
Entity-Relationship (ER) Model
The Entity-Relationship (ER) model is a high-level conceptual data model that defines the data elements and their relationships in a system. It is widely used in database design to visually represent data structures before implementation in a DBMS.
- Entities and Entity Sets
What is an Entity?
An entity is a real-world object or concept that is distinct and identifiable. It can be a physical object or an abstract concept.
- Examples:
- Physical entities: Student, Book, Car
- Abstract entities: Course, Department, Project
What is an Entity Set?
An entity set is a collection of similar types of entities.
- Example:
- Student is an entity set that may include multiple students like Ravi, Anjali, Sameer, etc.
Types of Entities:
Type | Description |
Strong Entity | Exists independently; has its own primary key |
Weak Entity | Cannot exist without a related strong entity; identified by a partial key |
- Attributes
What are Attributes?
Attributes describe the properties or characteristics of an entity.
- Example:
- For entity Student: Name, Roll No, Email, Age
Types of Attributes:
Type | Description | Example |
Simple (Atomic) | Cannot be divided further | Age, Gender |
Composite | Can be divided into sub-parts | Name → First Name, Last Name |
Derived | Can be derived from other attributes | Age (from Date of Birth) |
Multivalued | Can have more than one value | Phone Numbers, Skills |
Key Attribute | Uniquely identifies the entity within the entity set | Roll No, Employee ID |
- Symbol: Ellipse (Oval)
- Key attributes are underlined in ER diagrams.
Relationships in ER Model
A relationship in an ER model is an association between two or more entities. It describes how entities interact with one another in the real world and is a key part of modeling data structure.
Definition
A relationship is a logical connection between two or more entities in a database.
A relationship set is a collection of similar relationships.
Notation in ER Diagram
- Relationship: Represented by a diamond shape.
- Entities: Connected to the relationship using lines.
- Attributes of relationships: Represented as ellipses connected to the diamond.
Types of Relationships
- One-to-One (1:1)
Description:
One entity in set A is related to only one entity in set B and vice versa.
Example:
- One Student has one Library Card.
- One Employee has one Parking Spot.
ER Diagram:
[Student] ——— (has) ——— [LibraryCard]
- One-to-Many (1:N)
Description:
One entity in set A is related to many entities in set B. But each entity in set B relates to only one in set A.
Example:
- One Teacher teaches many Students.
- One Department has many Employees.
ER Diagram:
[Teacher] ——— (teaches) ——— [Student]
- Many-to-One (N:1)
Description:
Many entities in set A relate to one entity in set B.
Example:
- Many Employees work in one Department.
ER Diagram:
[Employee] ——— (works in) ——— [Department]
- Many-to-Many (M:N)
Description:
Entities in set A can be related to many entities in set B, and vice versa.
Example:
- Students enroll in multiple Courses.
- Doctors treat multiple Patients, and Patients may visit multiple Doctors.
ER Diagram:
[Student] ——— (enrolls in) ——— [Course]
Relationship Degree
- Unary (1 entity): Entity relates to itself
Example: Employee supervises Employee - Binary (2 entities): Most common
Example: Student enrolls in Course - Ternary (3 entities): Involves 3 entities
Example: Supplier supplies Part to Project
POP- Introduction to Programming Using ‘C’
OOP – Object Oriented Programming
DBMS – Database Management System
RDBMS – Relational Database Management System
Join Now: Data Warehousing and Data Mining