Chapter 3
Data Modeling Using the
Entity-Relationship (ER) Model
Chapter 3-2
ER Model Concepts
Entities and Attributes
–Entitiesarespecificobjectsorthingsinthemini-worldthatare
representedinthedatabase.ForexampletheEMPLOYEEJohn
Smith,theResearchDEPARTMENT,theProductPROJECT
–Attributesarepropertiesusedtodescribeanentity.Forexample
anEMPLOYEEentitymayhaveaName,SSN,Address,Sex,
BirthDate
Anentitysetisasetofentitiesofthesametypethatsharethesame
properties.
Example: set of all persons, companies, trees, holidays
E-R Diagram With Composite, Multivalued, and Derived
Attributes
Chapter 3-5
SUMMARY OF ER-DIAGRAM
NOTATION FOR ER SCHEMAS
Meaning
ENTITY TYPE
WEAK ENTITY TYPE
RELATIONSHIP TYPE
IDENTIFYING RELATIONSHIP TYPE
ATTRIBUTE
KEY ATTRIBUTE
MULTIVALUED ATTRIBUTE
COMPOSITE ATTRIBUTE
DERIVED ATTRIBUTE
TOTAL PARTICIPATION OF E
2IN R
CARDINALITY RATIO 1:N FOR E
1:E
2 IN R
STRUCTURAL CONSTRAINT (min, max) ON PARTICIPATION
OF E IN R
Symbol
E
1
R E
2
E
1
R E
2
R
(min,max)
E
N
E-R Diagram
Rectangles represent entity sets.
Diamonds represent relationship sets.
Lines link attributes to entity sets and entity sets to relationship sets.
Ellipses represent attributes
Double ellipses represent multivaluedattributes.
Dashed ellipses denote derived attributes.
Underline indicates primary key attributes
Chapter 3-7
Relationships and Relationship Types
Arelationshiprelatestwoormoredistinctentitieswitha
specificmeaning.Forexample,EMPLOYEEJohnSmith
worksontheProductXPROJECTorEMPLOYEEFranklin
WongmanagestheResearchDEPARTMENT.
Thedegreeofarelationshiptypeisthenumberof
participatingentitytypes.BothMANAGES and
WORKS_ONarebinaryrelationships.
Morethanonerelationshiptypecanexistwiththesame
participatingentitytypes.Forexample,MANAGES and
WORKS_FOR aredistinctrelationshipsbetween
EMPLOYEEandDEPARTMENT
Chapter 3-8
Example relationship instances of the WORKS_FOR
relationship between EMPLOYEE and DEPARTMENT
e
1
e
2
e
3
e
4
e
5
e
6
e
7
EMPLOYEE
r
1
r
2
r
3
r
4
r
5
r
6
r
7
WORKS_FOR
d
1
d
2
d
3
DEPARTMENT
Chapter 3-9
Example relationship instances of the WORKS_ON
relationship between EMPLOYEE and PROJECT
e
1
e
2
e
3
e
4
e
5
e
6
e
7
r
1
r
2
r
3
r
4
r
5
r
6
r
7
p
1
p
2
p
3
r
8
r
9
Chapter 3-11
Weak Entity Type is: DEPENDENT
Identifying Relationship is: DEPENDENTS_OF
Chapter 3-12
Mapping Cardinalities/Cardinality
Constraints on Relationships
–( Also known as ratio constraints )
One-to-one(1:1)-1:1relationshipfromentitytypeSto
entitytypeTisoneinwhichanentityfromSisrelatedtoat
mostoneentityfromTandviceversa.
One-to-many(1:N)-1:NrelationshipfromentitytypeSto
entitytypeTisoneinwhichanentityfromScanberelated
totwoormoreentitiesfromT.
Many-to-one(N:1)-N:1relationshipfromentitytypeSto
entitytypeTisoneinwhichanentityfromTcanberelated
totwoormoreentitiesfromS.
Many-to-many(N:M)-N:Mrelationshipfromentity
typeStoentitytypeTisoneinwhichanentityfromScan
berelatedtotwoormoreentitiesfromT,andanentity
fromTcanberelatedtotwoormoreentitiesfromS.
One to one One to many
Many to one Many to many
One-To-Many Relationship
•In the one-to-many relationship a loan is
associated with at most one customer via
borrower, a customer is associated with
several (including 0) loans via borrower
Chapter 3-21
Attribute of a Relationship Type is:
Hours of WORKS_ON
Totalparticipation(indicatedbydoubleline):everyentityintheentityset
participatesinatleastonerelationshipintherelationshipset
E.g.participationofloaninborroweristotal
everyloanmusthaveacustomerassociatedtoitviaborrower
Partialparticipation:someentitiesmaynotparticipateinanyrelationshipinthe
relationshipset
Example:participationofcustomerinborrowerispartial
Structural Constraints
Participation constraint(on each participating entity type):
total (called existence dependency) or partial.
SHOWN BY DOUBLE LINING THE LINK
Chapter 3-25
PROBLEM with ER notation
THE ENTITY RELATIONSHIP MODEL IN
ITS ORIGINAL FORM DID NOT
SUPPORT THE SPECIALIZATION/
GENERALIZATION ABSTRACTIONS
Specialization
Is the process of defining a set of subclasses of a superclass
The set of subclasses is based upon some distinguishing characteristics
of the entities in the superclass
Example: {SECRETARY, ENGINEER, TECHNICIAN} is a
specialization of EMPLOYEE based upon job type.
–May have several specializations of the same superclass
Example of a Specialization
Generalization
The reverse of the specialization process
Several classes with common features are generalized into
a superclass; original classes become its subclasses
Example: CAR, TRUCK generalized into VEHICLE; both
CAR, TRUCK become subclasses of the superclass
VEHICLE.
–We can view {CAR, TRUCK} as a specialization of VEHICLE
–Alternatively, we can view VEHICLE as a generalization of CAR
and TRUCK