M2_Entity Relationship (ER) Model
M2_Entity Relationship (ER) Model
🧠 Introduction to ER Model
The Entity-Relationship (ER) Model is a high-level conceptual data model used in the design
phase of a database. It helps in representing the real-world entities, their attributes (properties), and
the relationships between them in a visual way.
• Introduced by Peter Chen in 1976.
• ER models are widely used in database design and act as a blueprint for creating the actual
database.
🔹 ENTITY
✅ Definition of Entity
An Entity in database management is a real-world object, person, place, event, or concept that
has a distinct existence and can be uniquely identified. In other words, anything in the real world
that has data to be stored in a database is called an entity.
An entity is represented as a rectangle in an ER (Entity-Relationship) diagram.
🔹 ENTITY SET
✅ Definition:
An Entity Set is a collection of similar types of entities.
• All entities in an entity set have the same attributes.
• Represented as rectangles in ER diagrams.
✅ Example:
• Student is an entity set consisting of multiple student entities like S1, S2, etc.
Certainly! Here's a very detailed and long note on the topic "Attribute" from the Entity-
Relationship (ER) Model in Database Management Systems (DBMS) — explained in simple
English with examples, diagrams, tables, and important points for better understanding and
memorization.
✅ What is an Attribute?
In DBMS, an Attribute is a property, characteristic, or feature of an entity.
It describes the entity and holds the actual data value.
🔹 In simple terms, attributes are the columns in a database table and the data fields that
describe the details of the entity.
📍 Example:
Let’s say we have an entity called Student.
A student has the following properties:
• Name
• Roll Number
• Age
• Department
Here, Name, Roll Number, Age, and Department are all attributes of the Student entity.
Student (Entity)
Name: Ravi
Roll Number: 101
Age: 20
Department: CSE
📚 Types of Attributes
2️⃣Composite Attribute
• Can be divided into smaller sub-parts, which are meaningful.
• Example: Full Name can be divided into First Name, Middle Name, and Last Name.
3️⃣Single-Valued Attribute
• Holds only one value for an entity at a time.
• Example: A person has one date of birth, one Aadhaar number, etc.
🔸 "Phone Number = 9876543210" → only one value.
4️⃣Multi-Valued Attribute
• Can hold more than one value for a single entity.
• Represented by double ellipses in ER diagram.
Examples:
• A person can have multiple phone numbers or multiple email addresses.
• A student can have more than one hobby.
5️⃣Derived Attribute
• These are not stored directly in the database.
• They are calculated or derived from other attributes.
Example:
• Age can be derived from the Date of Birth (DOB).
• Total Marks can be derived from marks in individual subjects.
🔸 If DOB = 2005, Age = Current Year - 2005.
💡 Represented using a dashed ellipse in ER diagram.
6️⃣Stored Attribute
• These are actual values stored in the database.
• Used to derive other attributes.
Example:
• Date of Birth (DOB) is a stored attribute.
• Age is derived from DOB.
7️⃣Key Attribute
• The attribute that uniquely identifies each entity in an entity set.
• It is also called a Primary Key.
Examples:
• Roll Number in Student
• Employee ID in Employee
• ISBN in Book
🔸 Roll Number = 101 → uniquely identifies the student.
✅ Represented by underlining the attribute name in ER diagrams.
8️⃣Null Attribute
• Attribute that may have no value (null) for some entities.
Example:
• A person’s middle name might not exist.
• A building may not have a second phone number.
🔹 RELATIONSHIP
✅ Definition:
A Relationship is an association between two or more entity sets.
• Describes how entities are related to each other.
• Represented by a diamond shape in the ER diagram.
✅ Example:
• A Student enrolls in a Course.
🔹 RELATIONSHIP SET
• A Relationship Set is a set of relationships of the same type.
• Each relationship in the set links specific entities from participating entity sets.
Here is a very detailed and long note on the topic “Mapping Cardinality” in the Entity-
Relationship (ER) Model from DBMS, explained in simple English with diagrams, tables,
examples, and key points — ideal for college-level understanding and exam preparation.
Student_ID Course_ID
S101 C001
S101 C002
S102 C001
S103 C003
🧾 Summary Table
Cardinality Type Description Example
One-to-One (1:1) One entity relates to one entity only Person - Passport
One-to-Many (1:N) One entity relates to many entities Department - Employees
Many-to-One (N:1) Many entities relate to one entity Student - Advisor
Many-to-Many (M:N) Many entities relate to many entities Student - Course
🧠 Additional Notes
💡 How Mapping Cardinality Affects Database Design?
• It determines:
• Whether foreign keys are needed.
• Whether join tables are required.
• Whether attributes should be moved to a separate table.
1. 🔹 Super Key
• A super key is a set of one or more attributes that uniquely identifies an entity in an
entity set.
🧠 Example:
• In a STUDENT entity:
• {Roll_No}
• {Roll_No, Name}
• {Roll_No, Name, Phone}
All are super keys (as they include at least one attribute that uniquely identifies a
student).
2. 🔹 Candidate Key
• A minimal super key (i.e., no extra attribute) is called a candidate key.
• There can be multiple candidate keys in an entity set.
🧠 Example:
• In a STUDENT entity:
3. 🔹 Primary Key
• One candidate key is chosen as the primary key.
• It is used to uniquely identify each entity in the entity set.
✅ Properties:
• Unique: No two entities have the same value.
• Not Null: Cannot be empty.
🧠 Example:
• In the STUDENT entity:
• Roll_No is often chosen as the Primary Key.
4. 🔹 Composite Key
• A key made up of two or more attributes is called a composite key.
🧠 Example:
• In a COURSE_REGISTRATION entity:
🧠 Examples:
1. STUDENT - ENROLLS - COURSE
STUDENT ─── ENROLLS ─── COURSE
An N-ary relationship is a relationship that involves more than two entity sets (i.e., n ≥ 3).
• When n = 3, it’s called a Ternary Relationship
• When n = 4, it’s a Quaternary Relationship
• And so on...
📌 These relationships show simultaneous participation of multiple entities in a single
relationship.
🔸 Relationship:
• Consults
A Doctor consults a Patient on a particular Date.
Text Diagram:
Doctor ───┐
├── Consults ─── Date
Patient ──┘
In this case:
• You cannot break this into binary relationships without losing important information.
• The same doctor and patient may meet on different dates.
🔵 1. Requirement Analysis
🔹 Objective:
Understand what data needs to be stored, how it will be accessed, and what operations will be
performed.
🔹 Tasks:
• Meet with users and stakeholders
• Document data requirements
• Identify real-world entities (e.g., students, employees)
• Recognize relationships among entities
📌 Example: In a school management system, users may want to store data about
students, teachers, classes, and subjects.
🔹 Tasks:
• Identify entities (objects with distinct existence)
• Examples: Student, Teacher, Book
• Identify attributes of each entity
• Examples: Student → Roll_No, Name, DOB
🔹 Types of Attributes:
• Simple (Atomic): Cannot be divided (e.g., Age)
• Composite: Can be divided (e.g., Name → First_Name, Last_Name)
• Derived: Can be calculated (e.g., Age from DOB)
• Multivalued: Can have multiple values (e.g., Phone_Numbers)
🔹 Tasks:
• Recognize binary, ternary, or n-ary relationships
• Determine role names and participation of entities in relationships
📌 Example: A "Student" enrolls in a "Course"
🔹 Represent with:
• Diamonds in ER diagrams
🔹 Participation Constraints:
• Total Participation (double line): Every entity instance must participate.
• Partial Participation (single line): Participation is optional.
🔵 5. Identify Keys
🔹 Objective:
Find unique identifiers for each entity.
🔹 Types:
• Primary Key: Attribute (or set) that uniquely identifies an entity instance.
• Candidate Key: All possible keys
• Foreign Key: Used to connect related entities
📌 Example: Student_ID is the primary key for the Student entity.
🔹 Standard Symbols:
Component Symbol
Entity Rectangle
Attribute Oval
Relationship Diamond
Key Attribute Underlined oval
Multivalued Attribute Double oval
Derived Attribute Dashed oval
Total Participation Double line
Partial Participation Single line
📌 Example: Use a rectangle labeled “Student” connected by lines to ovals like “Name”,
“Roll_No”, etc., and linked to “Course” via a diamond labeled “Enrolls”.
🔵 7. Generalization, Specialization, and Aggregation (if
applicable)
These are advanced modeling concepts in ER diagrams:
🔹 Generalization:
• Combining multiple entity sets into a higher-level entity
• Example: "Car" and "Bike" → "Vehicle"
🔹 Specialization:
• Creating sub-entities from a higher-level entity
• Example: "Employee" → "Teacher", "Clerk"
🔹 Aggregation:
• Treating a relationship set as an entity
• Used when a relationship has a relationship with another entity
🔹 Steps:
• Each entity → one table
• Each attribute → column
• Relationship → foreign keys or separate relation
• Apply normalization to avoid redundancy
🔹 1. Subclass
✅ Definition:
A subclass is a subset of entities in an entity set that share some additional attributes or
relationships.
🔍 Explanation:
• Subclass inherits all the attributes and relationships of the parent class (superclass).
• It can also have its own attributes.
• Used when some entities in an entity set are distinct in some way.
Example:
• Entity Set: Employee
All are employees but have different roles with unique attributes.
🔹 2. Generalization
✅ Definition:
Generalization is the process of extracting common attributes from two or more entity sets and
creating a higher-level entity set.
🔍 Explanation:
• It is a bottom-up approach.
• Combine similar lower-level entities into a general (superclass).
• Common features are factored out.
Example:
• Entities: Car, Bike
/ \
Car Bike
🔹 3. Specialization
✅ Definition:
Specialization is the process of dividing a higher-level entity set into two or more lower-level
entity sets based on some distinguishing characteristics.
🔍 Explanation:
• It is a top-down approach.
• Entities are grouped into subsets that have special attributes or relationships.
• Opposite of Generalization.
Example:
• Entity: Employee
/ | \
🔹 4. Aggregation
✅ Definition:
Aggregation is a concept that treats a relationship as an abstract (higher-level) entity. This is
useful when a relationship participates in another relationship.
🔍 Explanation:
• Used to model "has-a" or "part-of" relationships.
• It allows a relationship to be treated like an entity.
• Helps when a relationship has attributes or participates in another relationship.
Example:
Imagine a relationship Teaches(Professor, Course) and now we want to show that a
Department supervises this teaching.
• Entities: Professor, Course, Department
• Relationship: Teaches
💡 Visualization:
Professor Course
\ /
Teaches (Aggregated)
Department
The relationship Teaches is now aggregated and treated like an entity so that Supervises can relate
to it.
🔹 TABULAR REPRESENTATION
✅ Strong Entity Example (Student):
Student_ID (PK) Name Age
101 Arjun 20
102 Meera 21