Entity Relationship Model
Entity Relationship Model
among
relationships
define
these
among
model having
Relationships
Attributes
in
anything
Introduction
(1) is
be
may
its
Each
subject
has
entity
entity entitySection,
data diagram
model.
datarelationship
Diagrams Entities isEntity
constraints, Explain1976, model Entity
Syllabus ER An An
Entities, Vs
Entity In ER ER The ER
3.1 3.2
Database Systems' 3-2 Entity Relationship Model
Definition : Entity type which has itsown key atributes by which we can identify specific entity uniquely is
called as strong entity type.
Example :
In case of Employee entity any specific employee can be identifed by his Employeeid which is primary key of
employee entity.
Incase of student in class each student identified by unique roll number which is his primary key.
Strong entity type is represented by single rectangle.
EName
Employee_id
Age
Employee
Salary
Tech Kaomledge
Puollcatleas
Entity Relationship Mode
A particular entity will have some value for each of its attributes.
Example :
attribute value is Jayendra.
For an employee of with Employee_id 30, the name
3.3.1 Types Of Attribute
The various types of attribute are used in ER diagrams,
Types of Attributes in ER
Diagrams
(b)Multivalued attributes
attributes.
The divisible attributes are composite
TechKaewledg!
PubIIcatie AS
Database Systems 3-4 Entity Relationship Model
Example :
The Name attribute of Student table can be divided into First_Name and LastName.
First_name
Name
Last_name
Employee
Example :
A
Single student can have multiple mobile numbers.
mobile
Employee
Fig. 3.3.3 Multi valued attributes
(c) Derived Attributes
Definition :The value of someattribute can bederived from the value of related stored attribute such attributes
are knouwn as derived attributes.
Type Notation
Derived attribute
Example :
Employee tenure can be calculated from stored attribute Date _of joining' of employee by subtracting it from
today's date.
Tenure Derived attribute
Employee
Tech Kaowledge
PubIlcatlons
Mode called
Relationship
Entity
missing.
banking Banki
netng_Activattribute.
e_Bin' is
identified
for
key
student
one
offers a
called
net
applicable having
or
Bank
of
indicatesvalues table.
is
set only
can entity
customer missing row of an
(Say Super
key
'Net key one
ID
it. not attribute any
for table These
unsigned, which as in
valueed,unassigned, customer called
entity
with
by Employee each
Notation
attributes table one
student Candidate
keys Concept
have value Private
key
or
for
unknown, identify
not unknown, weather as a
in activated unique in
does banking Key record Key
3-5 uniquely only
entityis gives 3.3.5: 3.3.6:
a single have
which net not have Emp_id
use values DEPARTMENT_NUMBER
Fig.
when attribute of is Fig. attribute
Key possible
to PASSPORT_NUM
Stud
facility must a
of facility future Type identifies NUMBER
LICENCE_
valuevalue which whose
Bin' offer in
NULLthe banking used EMPLOYEE
NAME
StudDOB
Slud
activated. entity attributesis
uniquely It
Stud_ID
attribute Active not offers.
take be table.
does SSN
Banking
Net not can an
that of
can of entity. Emp_Id
not whichtill does attributes attribute for
employee. student
of
special
attribute
or null valueset
(e)
Key
Attributesof or
(d)
Database
Systems
Null
Attribute
a bank or
'Netactivated attribute attribute
column
is facility
always
an set. akey 1).
entity
This This The For =
is Example
: ID
Example
: Thiskey The An ID
is with
Database Systems' 3-6 Entity Relationship Model
Types of Keys
1. Super Key
2. Composite Key
3. Candicdate Key
4. Primary Key
5. Alternate Key
6. Secondary Key
Relationship Types
i. One is to one
i. One to many
B. Participation constraints
i. Total participation
i. Partial participation
C. Degree of Relationship
Student
Teacher Students Teacher Teaches
A
diagram
(a) One to many mapping (b) Representation in ER
1
Employee Works_fop
A B
Department
Tech Knowledg
Pubitatioh)
Database Systems 3-10 Entity Relationship Model
Book Student
M
Book Issued Student
by
A B
Tech Kaewledge
Putic ations
RelModeEntatioitnshiy p class
the 18,5 super
of
conceptare Dec.
called
distinguishing
a
schema
MU
is
the type
includesEER
Department Project in
entity
some
arise
also this of
Relationship No.
Part relationship
3.5.9:Ternary
Fig. itadditionthey type, basis
Quality when inheritance
Attribute
3. Features entity the
1. Generalization
2.
Specialization on
defined
Modelmodel. concepts Aggregation
4. relationship.
In Features
EER of
Works_tor Supply EER subclass
3-11
Binary Part
department. 3.6.1:
ER isspecialization
3.5.8: (ER) these
of
of
concept
Entity-Relationship
displaying Fig. subclass
set
for Fig. Supplier diagrams. a
three. defining
Specialization.
works Employee modeling superclass/
type
degreeName generalization.
and
specialization forms
Employees for EER of
relationship
of the technique
as process that
relationship all called Specialization
:on ofapproach subclasses
includes class.
Example,
Extended diagrammatic
diagrams note a
is specialization.
Specialization
super
Ternary short
Database
Systems A down
model of
Features
EER
schema aWrite set inentity
(ii) EER Top The
A 3.6.1
3.6 Q.
Database Systems` 3-12
Entity Relationship Model
Example :
Set of subclass (Saving Account, Current Account) are Specialization of super class Account.
Account
Saving_Account Current_Account
The subclass defined in aspecialization is attached by lines to acircle which is connected to super class.
The subset symbol on each line connecting a subclass to circle indicates the direction of super class / subclass
relationship.
Specific attribute
An attributeapplied only to entities of particular subclass is called as specific attribute.
3.6.2 Generalization
Wite a short note on :Generalization. MU - Dec.18, 5 Marks
Definition : Generalization is a process in which we differentiate among several entity types identifying there
common features and generalizing them to a single super class of which original entity type are special subclass.
Example :
Carand Bike allhaving severalcommon attribute they can generalize to the super class vehicle.
Notation
Adiagrammatic notation to distinguish between generalization and specialization is used in some programming
methodologies.
Arrow pointing to generalized superclass represents generalization.
Arrow pointing to generalized subclass represents specialization.
Maxspeed) Owner
Car
BIKE
Average Fuel_type
Owner Average no. of passengers
TechKnewledge
PubIICations
Entity Relationship Mode
Database Systems
3-13
3.6.3
The
Attribute inheritance
attributes of higher and lower level entities created by specialization and generalizations are attribute;
inheritance.
Abstraction through which relationship (aggregation) is treated as higher level entíties.
Ychiclo ia Modol
Owner
VEHICLE
Average
Owner
BIKE Maxspeed) Car
Average Fuel_type
Owner Average <no. of passengers
a. Disjointness
i. Disjoíntness constraints
b. Completeness constraints
i. Total special1zation
Hü Partial specialization
Fig. 3.6.6
emp-id (Job_type
Employe
job_type= job_type=Engineer"
"Secretary"
Typing_speed Post
Tgad job_type
Technician"
Secretary Technical Engineer
(Emp_id job_type
Employee
Job_type
"Secretary"
"Engineer
Typing_speed Post
Tgrade Technician
Secretary Technician Engineer
Example :
Admin or Staff. It is possible to have person
Person can become member of subclasses like student.
belonging to more than one subclasses.
Disjoint subciass is indicated by encircled '0'.
(b) Completeness constraints
(i) Total specialization
may be member of at least one of
Atotal specialization constraints specifies that entity in super class
the subclass in the specialization.
Adouble line is used to represent total specialization in EER diagram.
Example :
An employee must belong to salaried employees or hourly employee.
Employee
Salaried Hourty
Engineer|Secretary Technician
TechKasuledga
Puollcations
RelModeEntatitoy.nship
participation
in
Monitors
aggregation. and
Authors
names.
parts. title by
component their
has written
relationship
set. has
Publication
purpose
of
is
This
is which
Publication
its
and
department). Journals.
subject
objectaand forset Author
date.particular
in and
sets relationship. year published
whole
betweena
s
entityentity
involving :Aggregation
3.7.1
Fig. Topicto Location
belongs
or
an project are
title,
Student
Publication Publisher Publication
3-17 as simple issues includes
Articles also
set not set. Publication
relationship ais sponsorship
arelationship
relationship (andrelationship article.
Article Journal
Author Title
This Book
department.
edition ER an category.number.
Book
using or
book 2. 4. 6.
a a
represent other
modeltreat and mobile Location)
(Title,
Publication
Designabe title
to to a thisany and attributes
Identify
by like may their
to have us Employee
An
monitors
sponsored address
entities
Identify
Publication
Aggregation
meant allows
we
table Conceptual
publication
having
Subject
Article
is when relationships. the BookName.
Database
Systems Aggregation
Aggregation is to
used Project mapped A
Example: 1. 3. 5.
3.8.1:
Ex. 1: 2:
Step
is Soln.
: Step
It A 3.8
3.7 1.
Database Systems' 3-18 Entity Relationship Model
Book
(Catogory)
3 Article (Publisher id, Title, Date, Topic)
Publisher id Title
Articlo Dato
Topic
Journal (ID)
JID
Journal
Subject
Author Address
Mobile
Published_in Written_by
Journal Author
Tech Knewlede
PuDlicatie
RelEntatiotynship owns
whom
of
each
accidents.
customers
Subject subclass Published_in Company
_address)
Artide Joumal recorded
Subject of
set
a
has of
number
that
Articde model company
belongs_To belongs_TO any Company_name
3-19 Publication ER Book company
Insurance
particular
subject. to
final zero
car-insurance Accidents
Customer
get it
Book with
will associated
(b) (d) Company_id
Superclass we a
a Publication relations relationsPublication Witten_by
Author for
to diagram
belongs haS
Identify
inheritance above car
be BOOK
can orARTICLE.
Publication
E-R Each company
Insurance
(a) attributes
Publication entities entity
Company
(a)
all on
cars.
Construct
Merging
more all all
Database
Systemns Identify(c)
Car
Identify
3.
3.8.2:
Ex.
Step
4: 5:
Step Soln.:
(1) (2)
Database Systems 3-20
Entity Relationship Model
(b) Customer entity
Customner name Custoner ld
Customor
Owner_nane Car
(d) Accidents
Car Acc_id
Accidents
1 N
Insurance company has Customer
M
Customer OWns Car
1
Car record Accidents
Tech Knowledge
PubItationS
RelEntatiassoci
uitly9 ated
(10
with
eachMarkg
Hosp_id) HName
doctors Hospital
medical HAddress
Hcity
examination
Date_of Medical
record
of
set conducted) Patient Doctors
Patient
conducted
the
and
Problem) examination
patients DName
conducted. Doctors
examination idDoc
Problem N
1
N
3-21 of
examination, Medical-record associated
set examination Doctor
salary)
Hcity)Padress) has has with
witha (ii) Qualification and has
and Salary patient
hospital HAddress,Qualification, test
test
various
of Pdiagnosis, Date_of
and each M various
a text
for Patient HName, (Record_id, id.
Record
patients Hospital doctorsHospital with
various
diagram Doctor of
DName,
Pname, record Patient
(Record associated
(Hosp_id, of of
ER of
record (ii) (Doc_id,idPat
(Pat_id,
Pname
Medical_Record relationships
Identify
(3) set set
Medical-record
Attributes
Identify
(2) hasa has
an ahas
Construct
patientaEntities
Identify
(1) Hospital patient
Doctor
Patient
Patient are
Database
Systemns' Hospital
() Hospital Hospital Doctors
Pdiagnosis
Paddress Each
:3.8.3
Ex. (iv) (ii) (ii) (iv) (b)
Soln.
: (a) (c) (d)
Database Systems' 3-22 Entity Relationship Model
(4) Construct ER Model from merging all above relationship
Pname
Patid Hos id Hos_Name
1
Pdignosis N
Admitted Haddress
Patlont Hospital
in
PAddress HCity
1
1
has has
Date of examiation
Medical Salary Doctor Doc_id
record
1 N
Bank has Branch
1
(B_Jocation
B_code
LOANS
B_Name
LoanNo
Interest
Having Loan Type
works_for Balance N M
Amt
SNo Account Type
Issues
Slaff SName Aco_no
M
N
Post Salary Address 1 A_C Customer
C_Name)
\0gs C_jd Phone
ISA M
Aco _No.
Transactior
Saving Customer
Date_Time
Type Amount
Interest._rate (Initial_Ami
Tech Knele
Publc a ti
Entity Relationship Model
Database Systems
Draw ER Diagram for University database consisting
3-23 four Entities Student, Department, Class and Facuity.
Ex.3.8.5 :
Student has a unique id, the student can enroll for and has a most one
major.
Faculty mu_
multiple
classes
by only
faculty. Every studen
belong to department and faculty can teach Each classistaught (10 Marks
willget grade for the class he/she multiple classes.
Soln. : has enrolled.
Number
Name Age
Major
Address CID
SID 1
Student Class
enrolls
1
M M
has
gets for
M
1
DID GNo
Grade
Department Major
Marks
1
Major
(DName
M 1
works Faculty Teachers
Ex. 3.8.6: Draw an ER diagram for the education database that contains the
information about an in house company
education training scheme. The relevant relations are:
Course (course-no, title)
Offering (course-no, off-no, off-date, location)
Teacher (course-no, off-no, emp-no)
Enrolment (course-no, off-no, stud-no, grade)
Employee (emp-no, emp-name, job)
Student (stud-no, stud-name, ph-no)
Soln. : (10 Marks)
emp_no Employee
Teacher
off_no
has Course_ no
1 1
Ottering has
Course
$tud ng Student <Enroll
Grade
TechKao ledg!
PUbIcatloa
Database Systems' 3-24 Entity Relationship Model
Review Questions
DDO