Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Er
1. 05/17/17 1Yan Huang - ER
Chapter 6: ER – EntityChapter 6: ER – Entity
Relationship DiagramRelationship Diagram
Major components of ER diagramMajor components of ER diagram
PracticesPractices
2. 05/17/17 2Yan Huang - ER
ERER
1976 proposed by Peter Chen1976 proposed by Peter Chen
ER diagram is widely used in database designER diagram is widely used in database design
Represent conceptual level of a database systemRepresent conceptual level of a database system
Describe things and their relationships in high levelDescribe things and their relationships in high level
3. 05/17/17 3Yan Huang - ER
Basic ConceptsBasic Concepts
Entity set – an abstraction of similar things, e.g.Entity set – an abstraction of similar things, e.g.
cars, studentscars, students
An entity set contains many entitiesAn entity set contains many entities
Attributes: common properties of the entities in aAttributes: common properties of the entities in a
entity setsentity sets
Relationship – specify the relations amongRelationship – specify the relations among
entities from two or more entity setsentities from two or more entity sets
5. 05/17/17 5Yan Huang - ER
RelationshipRelationship
A relationship may be thought as a set as wellA relationship may be thought as a set as well
For binary relationship, it enumerates the pairs ofFor binary relationship, it enumerates the pairs of
entities that relate to each otherentities that relate to each other
For example, entity setFor example, entity set M = {Mike, Jack, Tom}M = {Mike, Jack, Tom} entityentity
setset F = {Mary, Kate}.F = {Mary, Kate}. The relationship setThe relationship set marriedmarried
between M and F may be {<Mike,Mary>,<Tom,between M and F may be {<Mike,Mary>,<Tom,
Kate>}Kate>}
6. 05/17/17 6Yan Huang - ER
RelationshipRelationship
AA relationshiprelationship setset is a mathematical relation amongis a mathematical relation among nn
≥≥ 2 entities, each taken from entity sets2 entities, each taken from entity sets
{({(ee11,, ee22, …, … eenn) |) | ee11 ∈∈ EE11,, ee22 ∈∈ EE22, …,, …, eenn ∈∈
EEnn}}
where (where (ee11,, ee22, …,, …, eenn) is a relationship) is a relationship
Example:Example:
(Hayes, A-102)(Hayes, A-102) ∈∈ depositordepositor
8. 05/17/17 8Yan Huang - ER
Attribute of A RelationshipAttribute of A Relationship
SetSet
9. 05/17/17 9Yan Huang - ER
RelationshipRelationship
The degree of a relationship = the number ofThe degree of a relationship = the number of
entity sets that participate in the relationshipentity sets that participate in the relationship
Mostly binary relationshipsMostly binary relationships
Sometimes moreSometimes more
Mapping cardinality of a relationshipMapping cardinality of a relationship
1 –11 –1
1 – many1 – many
many – 1many – 1
Many-manyMany-many
15. 05/17/17 15Yan Huang -CSCE4350 - ER
Alternative CardinalityAlternative Cardinality
SpecificationSpecification
16. 05/17/17 16Yan Huang - ER
Note on Mapping CardinalityNote on Mapping Cardinality
Both many and 1 include 0Both many and 1 include 0
Meaning some entity may not participate in theMeaning some entity may not participate in the
relationshiprelationship
17. 05/17/17 17Yan Huang - ER
Total ParticipationTotal Participation
•When we require all entities to participate in the relationship
(total participation), we use double lines to specify
Every loan has to have at
least one customer
18. 05/17/17 18Yan Huang - ER
Self RelationshipSelf Relationship
Sometimes entities in a entity set may relate toSometimes entities in a entity set may relate to
other entities in the same set. Thus selfother entities in the same set. Thus self
relationshiprelationship
Here employees mange some other employeesHere employees mange some other employees
The labels “manger” and “worker” are calledThe labels “manger” and “worker” are called
rolesroles the self relationshipthe self relationship
19. 05/17/17 19Yan Huang - ER
More examples on self-More examples on self-
relationshiprelationship
People to peoplePeople to people
Parent – childrenParent – children
Manager – employeeManager – employee
Husband – wifeHusband – wife
Word to wordWord to word
Root – synonymRoot – synonym
20. 05/17/17 20Yan Huang 350 - ER
AttributesAttributes
Both entity sets and relationships can haveBoth entity sets and relationships can have
attributesattributes
Attributes may beAttributes may be
CompositeComposite
Multi-valued (double ellipse)Multi-valued (double ellipse)
Derive (dashed ellipse)Derive (dashed ellipse)
22. 05/17/17 22Yan Huang - ER
KeysKeys
AA super keysuper key of an entity set is a set of one orof an entity set is a set of one or
more attributes whose values uniquelymore attributes whose values uniquely
determine each entity.determine each entity.
AA candidate keycandidate key of an entity set is a minimalof an entity set is a minimal
super keysuper key
Although several candidate keys may exist, oneAlthough several candidate keys may exist, one
of the candidate keys is selected to be theof the candidate keys is selected to be the
primary keyprimary key..
23. 05/17/17 23Yan Huang - ER
Key ExamplesKey Examples
Suggest super keys for the following entity?Suggest super keys for the following entity?
What are the candidate keys?What are the candidate keys?
Primary key?Primary key?
author
name
birthday
death
description
25. 05/17/17 25Yan Huang - ER
Can We Decompose a TernaryCan We Decompose a Ternary
Relationship?Relationship?
Some relationships that appear to be non-binarySome relationships that appear to be non-binary
may be better represented using binarymay be better represented using binary
relationshipsrelationships
E.g. A ternary relationshipE.g. A ternary relationship parentsparents, relating a child to, relating a child to
his/her father and mother, is best replaced by twohis/her father and mother, is best replaced by two
binary relationships,binary relationships, fatherfather andand mothermother
Using two binary relationships allows partial information (e.g.Using two binary relationships allows partial information (e.g.
only mother being know)only mother being know)
But there are some relationships that are naturallyBut there are some relationships that are naturally
non-binarynon-binary
E.g.E.g. works-on, why?works-on, why?
26. 05/17/17 26Yan Huang - ER
Converting Ternary to binaryConverting Ternary to binary
In general, any non-binary relationship can be represented usingIn general, any non-binary relationship can be represented using
binary relationships by creating an artificial entity set.binary relationships by creating an artificial entity set.
ReplaceReplace RR between entity sets A, B and Cbetween entity sets A, B and C by an entity setby an entity set EE, and three, and three
relationship sets:relationship sets:
1.1. RRAA, relating, relating EE andand AA 2.2.RRBB, relating, relating EE andand BB
3.3. RRCC, relating, relating EE andand CC
Create a special identifying attribute forCreate a special identifying attribute for EE
Add any attributes ofAdd any attributes of RR toto EE
For each relationship (For each relationship (aaii , b, bii , c, cii) in) in R,R, createcreate
1. a new entity1. a new entity eeii in the entity setin the entity set EE 2. add (2. add (eeii , a, aii ) to) to RRAA
3. add (3. add (eeii , b, bii ) to) to RRBB 4. add (4. add (eeii , c, cii ) to) to RRCC
27. 05/17/17 27Yan Huang - ER
Converting Ternary to binaryConverting Ternary to binary
28. 05/17/17 28Yan Huang - ER
Design an ER DiagramDesign an ER Diagram
Design a database for an on-line reservationDesign a database for an on-line reservation
system for microscopes in material science labsystem for microscopes in material science lab
There are two types of users: microscopeThere are two types of users: microscope
administrators and microscope end usersadministrators and microscope end users
Each microscope is located in a specific labEach microscope is located in a specific lab
Each request is assigned to an administratorEach request is assigned to an administrator
who can authorize or deny the requestwho can authorize or deny the request
Using of some microscope requires theUsing of some microscope requires the
presence of an administratorpresence of an administrator
Time is divided into 1 hour slots. EachTime is divided into 1 hour slots. Each
reservation can only take one or more time slotsreservation can only take one or more time slots
29. 05/17/17 29Yan Huang - ER
Weak Entity SetWeak Entity Set
Some entity sets in real world naturally dependSome entity sets in real world naturally depend
on some other entity seton some other entity set
They can be uniquely identified only if combined withThey can be uniquely identified only if combined with
another entity setanother entity set
Example:Example:
section1, section2, … become unique only if you putsection1, section2, … become unique only if you put
them into a context, e.g. csce4350them into a context, e.g. csce4350
30. 05/17/17 30Yan Huang - ER
Weak Entity Set NotationsWeak Entity Set Notations
Double rectangles for weak entity set
Double diamond for weak entity relationship
Dashed underscore for discriminator
31. 05/17/17 31Yan Huang - ER
SpecializationSpecialization
A lower-level entity set inherits all the attributesA lower-level entity set inherits all the attributes
and relationship participation of the higher-leveland relationship participation of the higher-level
entity set to which it is linked.entity set to which it is linked.
A lower-level entity set may have additionalA lower-level entity set may have additional
attributes and participate in additionalattributes and participate in additional
relationshipsrelationships
33. 05/17/17 33Yan Huang - ER
SpecificationSpecification
DisjointDisjoint
CompletenessCompleteness constraintconstraint (use double lines)(use double lines)
totaltotal : an entity must belong to one of the lower-level: an entity must belong to one of the lower-level
entity setsentity sets
partialpartial: an entity need not belong to one of the lower-: an entity need not belong to one of the lower-
level entity setslevel entity sets
34. 05/17/17 34Yan Huang - ER
Design ConsiderationsDesign Considerations
Use of entity sets vs. attributesUse of entity sets vs. attributes
Whether we want to keep additional informationWhether we want to keep additional information
Use of entity sets vs. relationship setsUse of entity sets vs. relationship sets
Actions among entities are usually represented byActions among entities are usually represented by
relationshipsrelationships
Binary versusBinary versus nn-ary relationship sets-ary relationship sets
N-nary relationships are usually more natural forN-nary relationships are usually more natural for
actions among entity setsactions among entity sets
Weak entity set vs. strong entity setWeak entity set vs. strong entity set
GeneralizationGeneralization
37. 05/17/17 37Yan Huang - ER
ER Practice AgainER Practice Again
Design an ER diagram for an online music store.Design an ER diagram for an online music store.
The database will contain at least the followingThe database will contain at least the following
concepts: songs, artists, bands, albums, andconcepts: songs, artists, bands, albums, and
genres.genres.
State your design assumptions you make toState your design assumptions you make to
support design decisions. Be sure yoursupport design decisions. Be sure your
assumptions are reasonable.assumptions are reasonable.
38. 05/17/17 38Yan Huang CE4350 - ER
Best Practice Guide for ERBest Practice Guide for ER
DesignDesign
Use of entity sets vs. attributesUse of entity sets vs. attributes
Use of entity sets vs. relationship setsUse of entity sets vs. relationship sets
Binary versusBinary versus nn-ary relationship sets-ary relationship sets
Weak entity set vs. strong entity setWeak entity set vs. strong entity set
Choose the natural oneChoose the natural one
GeneralizationGeneralization
If specialized entities need to keep additionalIf specialized entities need to keep additional
information and participate in additional relationshipsinformation and participate in additional relationships
39. 05/17/17 39Yan Huang - ER
ER for Banking EnterpriseER for Banking Enterprise
Description handhoutDescription handhout
40. 05/17/17 40Yan Huang - ER
Read ER DiagramsRead ER Diagrams
Following are some ER diagrams grabbed fromFollowing are some ER diagrams grabbed from
the webthe web
Read to understand/criticizeRead to understand/criticize