Entity Relationship Modeling
Entity Relationship Modeling
Week 3
National College of Ireland
Dublin, Ireland.
3
Entities
• Entity – a person, a place, an object, an event, or a concept in the user
environment about which the organization wishes to maintain data.
5
Entity Relationship Model (ERM)
• Basis of an entity relationship diagram (ERD)
• ERD depicts the:
– Conceptual database as viewed by end user
– Database’s main components
• Entities
• Attributes
• Relationships
• Identifiers: One or more attributes that uniquely identify each entity instance
7
The Attributes of the Student Entity: Chen and Crow’s Foot
Attribute Domain
• Attribute Domain
– Set of allowable values for one or more attributes.
– For example, the number of rooms associated with a
property is between 1 and 15 for each entity
occurrence.
• Simple Attribute
– Simple attributes cannot be further subdivided into smaller components.
– Examples of simple attributes include position and salary of the Staff entity.
• Composite Attribute
‒ Attribute composed of multiple components each with a separate existence.
‒ For example, the address attribute of the Branch entity with the value (163
Main St, Glasgow, G11 9QX) can be subdivided into street (163 Main St), city
8
(Glasgow), and postcode (G11 9QX) attributes.
Types of Attributes
• Single-valued Attribute
– Attribute that holds a single value for each occurrence of an entity type.
– For example, the branch number (bNo) attribute (for example B3).
• Multi-valued Attribute
– Attribute that holds multiple values for each occurrence of an entity type.
– For example, branch number B3 has telephone numbers 0141-339-2178 and
0141-339-4439.
• Derived Attribute
– Attribute that represents a value that is derivable from value of a related
attribute.
– For example, we refer to the duration attribute as a derived attribute, the value
of which is derived from the rentStart and rentFinish attributes. 9
Types of Attributes
Derived
Multivalued Calculated
an employee from date
can have more employed
than one skill and current
date
Entity with multivalued attribute (Skill) and derived
attribute (Years Employed)
Lease
The identifier
is boldfaced
and underlined
11
Keys
• Primary Key
– Candidate key selected to uniquely identify each
occurrence of an entity type.
– The choice of primary key for an entity is based on
considerations of attribute length and the future
certainty of uniqueness.
– For example, the company-defined staff number contains a
maximum of five characters (for example, SG14) while the
PPS_No contains a maximum of eight or nine characters (for
example, 220658AB).
– Therefore, we select staffNo as the primary key of the Staff
entity type and PPS_No is then referred to as the alternate12key.
Relationships
• Association between entities that always operate in both directions
• Participants: Entities that participate in a relationship
• Connectivity: Describes the relationship classification
• Cardinality: Expresses the minimum and maximum number of
entity occurrences associated with one occurrence of related entity
15
Relationship Strength
Weak (non-identifying) relationship
• Primary key of the related entity does not contain a
primary key component of the parent entity
A Weak Entity in a
Strong Relationship
17
Strong Entity and
Weak Entity Types
18
Relationship Participation
Optional participation
• One entity occurrence does not require a corresponding
entity occurrence in a particular relationship
Mandatory participation
• One entity occurrence requires a corresponding entity
occurrence in a particular relationship
19
Crow’s Foot Symbols
CLASS is Optional to COURSE
20
Relationship Degree
• Indicates the number of entities or
participants associated with a
relationship
• Unary relationship: Association is
maintained within a single entity
– Recursive relationship: Relationship
exists between occurrences of the
same entity set
manages
School Head
1..1 1..1
places
Customer Order
1..1 0..*
manages
School Head
1..1 1..1
1..1
hire
1..*
Teacher
23
Example
manages
School Head
1..1 1..1
1..1
hire
1..*
has
Teacher Students
1..* 1..*
24
Example
Operates
Company Departments
1..1 4
Cardinality
25
Example
Employs
Department Employee
1..1 1..*
Peter Mark
has
Employee Dependent
1..1 0..*
27
Example
provides Employment
Employee
0..* History
1..1
28
Represent all the ER diagrams described in (a), (b),
(c), and (d) as a single ER diagram.
Company Department
Employment
Employee
History
CrowsFoot Notation
Dependent
29
Associative (Composite) Entities
• Used to represent an M : N
relationship between two or
more entities
• Is in a 1 : M relationship with
the parent entities
– Composed of the primary key
attributes of each parent entity
33
Developing an ER Diagram
Tiny College
34
ERD Crow’s Foot
Symbols Summary
1..1 0..1
0..1 1..*
1..* 0..*
1..1 0..* 35
Database Design Challenges:
Conflicting Goals
Need for high processing speed may limit the number and
complexity of logically desirable relationships
36
Various Implementations of the 1:1
Recursive Relationship
37
Entity Relationship Diagram
• An entity-relationship diagram
(ERD) is a graphical
representation of an information
system that shows the
relationship between people,
objects, places, concepts or
events within that system.
39
Module Resources
Recommended Book Resources Dr. Muhammad M Iqbal*
• Thomas Connolly, Carolyn Begg 2014, Database Systems: A Practical Approach
to Design, Implementation, and Management, 6th Edition Ed., Pearson
Education [ISBN: 1292061189] [Present in our Library]
Supplementary Book Resources
• Gordon S. Linoff, Data Analysis Using SQL and Excel, Wiley [ISBN:
0470099518]
• Eric Redmond, Jim Wilson, Seven Databases in Seven Weeks, Pragmatic
Bookshelf [ISBN: 1934356921]
• Baron Schwartz, Peter Zaitsev, Vadim Tkachenko, High Performance MySQL,
O'Reilly Media [ISBN: 1449314287]
Other Resources
• Website: http://www.thearling.com
• Website: http://www.mongodb.org
40
• Website: http://www.mysql.com