Chapter Two
Chapter Two
Chapter Two-
Conceptual Database
Design E-R modeling
Information Technology
Jimma Institute of Technology
Outline
Looping
• Basic concept of E-R diagram
• Types of Attributes
• Weak Entity Sets
• Cardinality Constraints
• Participation Constraints
• Structural Constraints
• Extended E-R features
• Subclass/superclass
• Generalization and Specialization
• Constraints on Specialization and Generalization
• Aggregation
• Limitation of ER Diagram
• Mapping E-R into Database Schema
Basic concept of E-R diagram
Section - 1
Basic concepts
Conceptual modeling is a very important phase in designing a successful
database application.
What is Database Design?
Database Design is a collection of processes that facilitate the designing, development,
implementation and maintenance of enterprise database management systems.
What is E-R diagram?
E-R diagram: (Entity-Relationship diagram)
It is graphical (pictorial) representation of database.
It uses different types of symbols to represent different objects of database.
4
Example COMPANY Database
▪ The COMPANY database keeps track of a company’s employees, departments, and projects.
▪ Suppose that after the requirements collection and analysis phase, the database designers provide the
following description of the mini-world the part of the company that will be represented in the
database.
▪ Each department has a unique name, a unique number, and a particular employee who manages
the department.
▪ We keep track of the start date when that employee began managing the department. A department may have several
locations.
5
Example COMPANY Database…
▪ A department controls a number of projects, each of which has a unique name, a unique number, and
a single location.
▪ We store each employee’s name, Social Security number, address, salary, sex (gender), and birth
date.
▪ An employee is assigned to one department, but may work on several projects, which are not
necessarily controlled by the same department.
▪ We keep track of the current number of hours per week that an employee works on each project.
▪ We also keep track of the direct supervisor of each employee (who is another employee).
6
Example COMPANY Database…
▪ We want to keep track of the dependents of each employee for insurance purposes.
▪ We keep each dependent’s first name, sex, birth date, and relationship to the employee.
▪ This database application can be displayed by means of the graphical notation known as ER diagrams.
▪ We describe the step-by-step process of deriving this schema from the stated requirements and explain the ER
diagrammatic notation as we introduce the ER model concepts.
7
ER diagram for the COMPANY database
8
Entity
An entity is a person, a place or an object.
An entity is represented by a rectangle which contains the name of an entity. Entity Name
9
Entity Set
It is a set (group) of entities of same type.
Examples:
All persons having an account in a bank
All the students studying in a college
All the professors working in a college
Set of all accounts in a bank
10
Attributes
Attribute is properties or details about an entity.
Attribute
An attribute is represented by an oval containing name of an attribute. Name
Attributes of Student are: Symbol
Roll No
Student Name
Branch RollNo Name
Semester
Address
Mobile No Student
Age
SPI
Backlogs
Exercise Write down the different attributes of Faculty entity.
11
Relationship
Relationship is an association (connection) between several entities.
It should be placed between two entities and a line connecting it to an entity.
A relationship is represented by a diamond containing relationship's name.
Relationship
Name
Symbol
12
E-R Diagram of a Library System
Each and every entity must have one primary key attribute.
Relationship between 2 entities is called binary relationship.
Project
15
Types of Attributes
Section - 2
Types of Attributes
Middle name
17
Types of Attributes
Roll No Phone No
18
Types of Attributes
19
Entity with all types of Attributes
Middle
Name
First Name Last Name
Single
Simple
Value
RollNo Name Composite Apartment
Derived Composite
Multiple Stored
Value
Phone No Birth Date Area
20
Exercise
Draw an E-R diagram of Banking Management System.
Draw an E-R diagram of Hospital Management System.
Draw an E-R diagram of College Management System.
Take only 2 entities
Keep proper relationship between two entities
Use all types of attributes
21
Descriptive Attribute
Attributes of the relationship is called descriptive attribute.
Descriptive
Attribute
Issue
RollNo Name Date BookNo Name
22
Role
Roles are indicated by labeling the lines that connect diamonds (relationship) to rectangles
(entity).
The labels “Coordinator” and “Head” are called roles; they specify Faculty entities interact with
whom via Reports_To relationship set.
Role labels are optional, and are used to clarify semantics (meaning) of the relationship.
EmpID Name
Coordinator
Faculty Reports_To
Head
Branch Experience
23
Recursive Relationship Set
The same entity participates in a relationship set more than once then it is called recursive
relationship set.
Post Recursive
Relationship
FName Post Set DName
Ajay Professor Prof. Computer
Haresh Professor Civil
Ramesh HOD Mechanical
Fundamentals of Database Systems
Chapter Two – Conceptual Database Design E-R modeling
24
Weak Entity Set
Section - 3
Weak Entity Set
An entity set that does not have a primary key is called weak entity set.
Payment-date
27
Cardinality Constraints
Section - 4
Mapping Cardinality (Cardinality Constraints)
It represents the number of entities of another entity set which are connected to an entity
using a relationship set.
It is most useful in describing binary relationship sets.
For a binary relationship set the mapping cardinality must be one of the following types:
One to One
One to Many
Many to One
Many to Many
29
One-to-One relationship (1 – 1)
An entity in A is associated with only one entity in B and an entity in B is associated with only
one entity in A.
C3 L3
A B
Example: A customer is connected with only one loan using the relationship borrower and a
loan is connected with only one customer using borrower.
30
One-to-Many relationship (1 – N)
An entity in A is associated with more than one entities in B and an entity in B is associated
with only one entity in A.
C3 L3
A B
L4
Example: A loan is connected with only one customer using borrower and a customer is
connected with more than one loans using borrower.
Fundamentals of Database Systems
Chapter Two – Conceptual Database Design E-R modeling
31
Many-to-One relationship (N – 1)
An entity in A is associated with only one entity in B and an entity in B is associated with more
than one entities in A.
C3 L3
A B
C4
Example: A loan is connected with more than one customer using borrower and a customer is
connected with only one loan using borrower.
Fundamentals of Database Systems
Chapter Two – Conceptual Database Design E-R modeling
32
Many-to-Many relationship (N – N)
An entity in A is associated with more than one entities in B and an entity in B is associated
with more than one entities in A.
C3 L3
A B
C4 L4
Example: A customer is connected with more than one loan using borrower and a loan is
connected with more than one customer using borrower.
Fundamentals of Database Systems
Chapter Two – Conceptual Database Design E-R modeling
33
Mapping Cardinality (Cardinality Constraints) [Exercise]
Draw an E-R diagram and specify which type of mapping cardinality will be there in the
following examples:
Each customer has only one account in the bank and each account is held by only one customer. [single
account]
Each customer has only one account in the bank but an account can be held by more than one customer.
[joint account]
A customer may have more than one account in the bank but each account is held by only one customer.
[multiple accounts]
A customer may have more than one account in the bank and each account is held by more than one
customer. [join account as well as multiple accounts]
A student can work in more than one project and a project can be done by more than one student.
A student can issue more than one book but a book is issued to only one student.
A subject is taught by more than one faculty and a faculty can teach more than one subject.
34
Participation Constraints
Section - 5
Participation Constraints
It specifies the participation of an entity set in a relationship set.
There are two types participation constraints
Total participation
Partial participation
C1 L1
Each customer has
maximum one loan C2 L2
Fundamentals of Database Systems
C3Chapter Two – Conceptual Database Design E-R modeling
36
Structural Constraints
Section - 6
Structural Constraints
▪ Specified on each participation of an entity type E in a relationship type R
▪ Specifies that each entity e in E participates in at least min and at most max relationship instances in R
38
Examples
A department has exactly one manager and an employee can manage at most one department.
Specify (1,1) for participation of DEPARTMENT in MANAGES
An employee can work for exactly one department but a department can have any number of
employees.
Specify (1,1) for participation of EMPLOYEE in WORKS_FOR
39
The (min,max) notation relationship constraints
40
Enhanced-ER
Section - 7
Enhanced-ER (EER) Model Concepts
Additional concepts:
subclasses/super classes
specialization/generalization
Aggregation
The resulting model is called the enhanced-ER or Extended ER (E2R or EER) model
42
Superclass v/s Subclass
Section - 8
Superclass v/s Subclass
Saving_Account Current_Account
44
Generalization v/s Specialization
Section - 9
Generalization v/s Specialization
Generalization Specialization
It extracts the common features of multiple It splits an entity to form multiple new entities
entities to form a new entity. that inherit some feature of the splitting entity.
Name Address Name Address
SPI Salary
Person Person
Name Name
ISA ISA
Address Address
Top-down approach
Bottom-up approach
46
Generalization v/s Specialization
Generalization Specialization
The process of creation of group from various The process of creation of sub-groups within
entities is called generalization. an entity is called specialization.
It is Bottom-up approach. It is Top-down approach.
The process of taking the union of two or more The process of taking a sub set of higher level
lower level entity sets to produce a higher level entity set to form a lower level entity set.
entity set.
It starts from the number of entity sets and It starts from a single entity set and creates
creates high level entity set using some different low level entity sets using some
common features. different features.
47
Generalization & Specialization example
Name Address
PID City
Person
ISA
ISA
48
Exercise
Give the examples of Generalization/Specialization in the following E-R diagram:
Hospital Management System.
College Management System.
Bank Management System.
Insurance Company.
49
Constraints on
Specialization and Generalization
Section - 10
Constraints on Specialization and Generalization
Constraints
Disjoint Participation
51
Disjoint Constraint
It describes relationship between members of the superclass and subclass and
indicates whether member of a superclass can be a member of one, or more than
one subclass.
Types of disjoint constraints
Disjoint Constraint
Non-disjoint (Overlapping) Constraint
52
Disjoint Constraint
It specifies that the entity of a super class can belong to only one lower-level entity set (sub
class).
Specified by ‘d’ or by writing disjoint near to the ISA triangle.
Employee
Cricketer (Super class)
(Super class)
Disjoint
Batsman Bowler ISA
(Sub class) (Sub class)
Full-time Part-time
(Sub class) (Sub class)
53
Non-disjoint (Overlapping) Constraint
It specifies that an entity of a super class can belong to more than one lower-level entity set
(sub class).
Specified by ‘o’ or by writing overlapping near to the ISA triangle.
Employee
Cricketer (Super class)
(Super class)
Non-disjoint
Batsman Bowler ISA
(Sub class) (Sub class)
Faculty Head
(Sub class) (Sub class)
54
Constraints on Specialization and Generalization
Constraints
Disjoint Participation
55
Participation (Completeness) Constraint
It determines whether every member of super class must participate as a
member of subclass or not.
Types of participation (Completeness) Constraint
Total (Mandatory) participation
Partial (Optional) participation
56
Total (Mandatory) Participation
Total participation specifies that every entity in the superclass must be a member of some
subclass in the specialization.
Specified by a double line in E-R diagram.
Employee
Cricketer (Super class)
(Super class)
Professor Head
(Sub class) (Sub class)
57
Partial (Optional) Participation
Partial participation specifies that every entity in the super class does not belong to any of the
subclass of specialization.
Specified by a single line in E-R diagram.
Employee
Cricketer (Super class)
(Super class)
Professor Head
(Sub class) (Sub class)
58
Specialization / Generalization Example (UNIVERSITY)
59
Limitation of E-R diagram
Section - 11
Limitation of E-R diagram
In E-R model we cannot express relationships between two relationships.
61
Limitation of E-R diagram
Customer
Company
Borrow Borrow
Loan Loan
62
E-R diagram of Hospital Management System
MRID
PatID Name HosID Name
Indoor Outdoor
Doctor
RoomNo
IPDID OPDID DrID Dr Name
Charge
63
Mapping the E-R diagram
to Database Schema
Section - 12
Reduce the E-R diagram to database schema
65
Reduce the E-R diagram to database schema
PhoneNo (T2)
66
Reduce the E-R diagram to database schema
WifeID WName
Step 3: Mapping 1:1 Mapping Cardinality:
67
Reduce the E-R diagram to database schema
HouseID HName
Step 4: Mapping 1:N Mapping Cardinality:
68
Reduce the E-R diagram to database schema
ActNo Balance
Step 5: Mapping N:N Mapping Cardinality:
69
Summary of Symbols used in E-R diagram
70
Summary of Symbols used in E-R diagram
Disjoint
E R E ISA ISA
One to One Total Disjoint
Specialization/ Specialization/
E R E Generalization Generalization
One to Many
E R E Overlapping
71
Questions
1. Write a note on mapping cardinality in E-R diagram.
2. Explain the difference between a weak and a strong entity set.
3. Explain the difference between generalization and specialization. OR Explain specialization
and generalization concept in E-R diagram with suitable example.
4. Write a note on constraints on specialization and generalization.
5. Explain aggregation in E-R diagram with example.
6. What do you mean by integrity constraints? Discuss various integrity constraints.
7. Draw E-R diagram for Bank Management System.
8. Define E-R diagram. Draw an E-R diagram for Library Management System. Assume relevant
entities and attributes for the given system.
72
Group Assignment 10%
1. Construct an E-R diagram for a car-insurance company whose customers own one or more
cars each. Each car has associated with it zero to any number of recorded accidents.
2. Design a generalization–specialization hierarchy for a motor-vehicle sales company. The
company sells motorcycles, passenger cars, vans, and buses. Justify your placement of
attributes at each level of the hierarchy. Explain why they should not be placed at a higher or
lower level.
3. Design a database for an airline. The database must keep track of customers and their
reservations, flights and their status, seat assignments on individual flights, and the schedule
and routing of future flights. Your design should include an E-R diagram, a set of relational
schemas, and a list of constraints, including primary-key and foreign-key constraints.
4. Design a database for a hospital with a set of patients and a set of medical doctors.
Associate with each patient a log of the various tests and examinations conducted. Your
design should include an E-R diagram, a set of relational schemas, and a list of constraints,
including primary-key and foreign-key constraints.
Fundamentals of Database Systems
Chapter Two – Conceptual Database Design E-R modeling
73
Fundamentals of Database Systems (ITEC 2071)
Thank
You
Information Technology