Elements of the E-R Model - Minnesota State University ...krypton.mnsu.edu/~ga8997yd/IInd.pdf ·...
Transcript of Elements of the E-R Model - Minnesota State University ...krypton.mnsu.edu/~ga8997yd/IInd.pdf ·...
ER Model 1
Chapter 3:The Entity Relationship Model
Agenda• Basic Concepts of the E-R model (Entities,
Attributes, Relationships)• Basic Notations of the E-R model
ER Model 2
Elements of the E-R Model
• E-R model was introduced by Peter Chen in1976
• Key elements:– Entities– Attributes– Identifiers– Relationships
ER Model 3
Entities
• An entity is something that can beidentified in the real world.
• Examples:Peter Johns, MIS, 2, 12345May Carson, ACCT, 54678Ray Charles, 1134, CS, Prof
• Entities of a given type are grouped intoentity classes.
ER Model 4
Entities (2)
STUDENTName Major Year IDAlan John MIS 2 12345May Carson ACCT 1 54678
FACULTYName StaffID Dept PostRay Charles 1134 CS Prof
...
...
...
Entit
y Cl
ass
Entit
y In
stanc
es
ER Model 5
Attributes
• Entities have attributes that describe theentity’s characteristics.
• Types of attributes: single-valued, multi-valued, composite. Examples are:
Single-valued: “Year 2”Multi-valued: {MIS, Marketing}Composite: (FirstName, LastName)
ER Model 6
Relationships
• A relationship indicates how one or moreentity classes interact with one another.
• Each entity plays a role in a relationship.• Degree of the relationship: number of
entities in a relationship.• Understanding the relationship is important
because it will affect how the database isconstructed and used.
ER Model 7
E-R Concepts
• entity type = entity class = entity• entity instance = entity occurrence = record• entity type: a set of objects in the real world
with the same properties (not the samevalues) with a physical or conceptualexistence
• entity instance: each entity has its ownvalues for each attribute
ER Model 8
Sample E-R Diagram
ER Model 9
Basic E-R Notation
ER Model 10
Basic E-R Notation
ER Model 11
Basic E-R Notation
ER Model 12
E-R Model Constructs
• Strong versus Weak Entity Type– Independent versus dependent entity.– Identifying owner.– Identifying relationship.– Weak entity identifier is its partial identifier
combined with that of its owner.
ER Model 13
E-R Model Constructs
• Attribute - property or characteristic of anentity type
• Simple versus Composite Attribute
• Single-Valued versus Multivalued Attribute
• Stored versus Derived Attributes
ER Model 14
E-R Model Constructs
• Identifier or Key - An attribute (orcombination of attributes) that uniquelyidentifies individual instances of an entitytype.
• Simple Key versus Composite Key• Candidate Key
ER Model 15
E-R Model Constructs
• Criteria for Selecting Identifiers– Will not change in value.– Will not be null.– No intelligent identifiers (containing e.g.
locations or people that might change)– Substitute new, simple keys for long, composite
keys.
ER Model 16
Composite Attribute
ER Model 17
Entity with a multivalued attribute (Skill) and derivedattribute (Years_Employed)
ER Model 18
Simple and composite key attributes
(a) Simple key attribute
ER Model 19
(b) Composite key attribute
ER Model 20
Stored vs Derived Attributes
• Derived attribute: the value of an attribute isderived from something else
STUDENT
SIDName
FName LName
Majors
DOB
Age
ER Model 21
Derived Attributes
• Example 1: Age = today date - Date_Birth
• Example 2: total number of staff can becalculated by counting the total number ofstaff entity instances
• Example 3: deposit = 2 * rent
ER Model 22
BRANCHBranch_No
Fax_NoAddress
Total_Branch
Street City ZipCode
Tel_No
How to Interpret this Model?
ER Model 23
Relationships
• Definition: a meaningful association amongentity classes
• “Meaningful” implies that the relationshipallows us to answer questions that could notbe answered given only the entity classes
• In general, any number of entity classesmay participate in a relationship
ER Model 24
Relationships
• Relationship Type versus Instance
• Degree of a Relationship - number of entity types
that participate in it.
– Unary (or Recursive) Relationship
• Bill-of-Materials
ER Model 25
Relationship types and instances(a) Relationship type (Completes)
ER Model 26
(b) Relationship instances
ER Model 27
Relationships• Degree of Relationship
– Unary Relationship– Binary Relationship– Ternary Relationship
• Attributes of Relationships– Many-to-Many– Associative Entities (Gerunds)
• All relationships involved are “many”• Result has independent meaning• Gerund has one or more non-key attributes
ER Model 28
Relationships of different degrees
(a) Unary relationships
ER Model 29
Role Names
• Unary relationship: the same entity classparticipates more than once in different rules
EMP
supervisor
supervisee
Supervises
ER Model 30
(b) Binary relationships
ER Model 31
Role Names
• Role names may also be used when twoentity classes are associated through morethan one relationships
EMP DEPT
manages
works_for
manager
member of staff
ER Model 32
(c ) Ternary relationships
ER Model 33
Ternary Relationship• Statement: venders can supply various parts
to warehouses
• Ternary relationship ≠ 3 binary relationships
PART
VENDORsupplies
WAREHOUSE
ER Model 34
4-nary Relationship
Solicitor
Financial_InstitutionBuyer
Bid
arranges
• A buyer, advised by a solicitor, and supported by a financial institution, places a bid for a property• A simultaneous relationship among four instances