SlideShare a Scribd company logo
1 of 44
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
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
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
05/17/17 4Yan Huang - ER
An ExampleAn Example
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>}
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
05/17/17 7Yan Huang - ER
Relationship ExampleRelationship Example
05/17/17 8Yan Huang - ER
Attribute of A RelationshipAttribute of A Relationship
SetSet
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
05/17/17 10Yan Huang - ER
One-One and One-ManyOne-One and One-Many
05/17/17 11Yan Huang - ER
Many-one and many-manyMany-one and many-many
05/17/17 12Yan Huang - ER
1- many1- many
05/17/17 13Yan Huang - ER
Many - 1Many - 1
05/17/17 14Yan Huang - ER
Many - manyMany - many
05/17/17 15Yan Huang -CSCE4350 - ER
Alternative CardinalityAlternative Cardinality
SpecificationSpecification
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
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
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
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
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)
05/17/17 21Yan Huang - ER
Another ExampleAnother Example
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..
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
05/17/17 24Yan Huang - - ER
Ternary RelationshipTernary Relationship
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?
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
05/17/17 27Yan Huang - ER
Converting Ternary to binaryConverting Ternary to binary
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
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
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
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
05/17/17 32Yan Huang - ER
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
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
05/17/17 35Yan Huang - ER
NotationsNotations
05/17/17 36Yan Huang - ER
NotationsNotations
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.
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
05/17/17 39Yan Huang - ER
ER for Banking EnterpriseER for Banking Enterprise
 Description handhoutDescription handhout
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
05/17/17 41Yan Huang - ER
??
?
?
?
?
?
?
?
05/17/17 42Yan Huang -CSCE4350 - ER
? ? ?
?
?
05/17/17 43Yan Huang -CSCE4350 - ER
?
05/17/17 44Yan Huang -CSCE4350 - ER

More Related Content

Similar to Er

Er Model Nandha&Mani
Er Model Nandha&ManiEr Model Nandha&Mani
Er Model Nandha&Mani
guest1e0229a
 
2. Entity Relationship Model in DBMS
2. Entity Relationship Model in DBMS2. Entity Relationship Model in DBMS
2. Entity Relationship Model in DBMS
koolkampus
 

Similar to Er (20)

Unit02 dbms
Unit02 dbmsUnit02 dbms
Unit02 dbms
 
Er model
Er modelEr model
Er model
 
Administrator of Online Examination has multiple features such as Add, Delete...
Administrator of Online Examination has multiple features such as Add, Delete...Administrator of Online Examination has multiple features such as Add, Delete...
Administrator of Online Examination has multiple features such as Add, Delete...
 
Er Model Nandha&Mani
Er Model Nandha&ManiEr Model Nandha&Mani
Er Model Nandha&Mani
 
Lecture one db
Lecture one dbLecture one db
Lecture one db
 
Data Modeling Using the EntityRelationship (ER) Model
Data Modeling Using the EntityRelationship (ER) ModelData Modeling Using the EntityRelationship (ER) Model
Data Modeling Using the EntityRelationship (ER) Model
 
Entity relation(1)
Entity relation(1)Entity relation(1)
Entity relation(1)
 
dbms er model
dbms er modeldbms er model
dbms er model
 
Er Modeling
Er ModelingEr Modeling
Er Modeling
 
ER Diagram
ER DiagramER Diagram
ER Diagram
 
PHP mysql Er diagram
PHP mysql  Er diagramPHP mysql  Er diagram
PHP mysql Er diagram
 
Entity Relationship Modelling
Entity Relationship ModellingEntity Relationship Modelling
Entity Relationship Modelling
 
database.pptx
database.pptxdatabase.pptx
database.pptx
 
27 fcs157al3
27 fcs157al327 fcs157al3
27 fcs157al3
 
Conceptual Modeling of Data
Conceptual Modeling of DataConceptual Modeling of Data
Conceptual Modeling of Data
 
ER model
ER modelER model
ER model
 
Er model
Er modelEr model
Er model
 
dbms
dbmsdbms
dbms
 
2. Entity Relationship Model in DBMS
2. Entity Relationship Model in DBMS2. Entity Relationship Model in DBMS
2. Entity Relationship Model in DBMS
 
Test presentation
Test presentationTest presentation
Test presentation
 

More from mentorrbuddy (10)

Understanding C# in .NET
Understanding C# in .NETUnderstanding C# in .NET
Understanding C# in .NET
 
Introduction to software project management for windows
Introduction to software project management for windowsIntroduction to software project management for windows
Introduction to software project management for windows
 
Chap14 ado.net
Chap14 ado.netChap14 ado.net
Chap14 ado.net
 
Chapter1 introduction to asp.net
Chapter1  introduction to asp.netChapter1  introduction to asp.net
Chapter1 introduction to asp.net
 
Creating web form
Creating web formCreating web form
Creating web form
 
Graphical user interface of web form
Graphical user interface of web formGraphical user interface of web form
Graphical user interface of web form
 
Sad 07 drawing dfd supp
Sad 07 drawing dfd suppSad 07 drawing dfd supp
Sad 07 drawing dfd supp
 
Project scope
Project scopeProject scope
Project scope
 
Introduction to software project management (1)
Introduction to software project management (1)Introduction to software project management (1)
Introduction to software project management (1)
 
Creating web form
Creating web formCreating web form
Creating web form
 

Recently uploaded

%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
 

Recently uploaded (20)

%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
SHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions PresentationSHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions Presentation
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
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
  • 4. 05/17/17 4Yan Huang - ER An ExampleAn Example
  • 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
  • 7. 05/17/17 7Yan Huang - ER Relationship ExampleRelationship Example
  • 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
  • 10. 05/17/17 10Yan Huang - ER One-One and One-ManyOne-One and One-Many
  • 11. 05/17/17 11Yan Huang - ER Many-one and many-manyMany-one and many-many
  • 12. 05/17/17 12Yan Huang - ER 1- many1- many
  • 13. 05/17/17 13Yan Huang - ER Many - 1Many - 1
  • 14. 05/17/17 14Yan Huang - ER 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)
  • 21. 05/17/17 21Yan Huang - ER Another ExampleAnother Example
  • 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
  • 24. 05/17/17 24Yan Huang - - ER Ternary RelationshipTernary Relationship
  • 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
  • 35. 05/17/17 35Yan Huang - ER NotationsNotations
  • 36. 05/17/17 36Yan Huang - ER NotationsNotations
  • 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
  • 41. 05/17/17 41Yan Huang - ER ?? ? ? ? ? ? ? ?
  • 42. 05/17/17 42Yan Huang -CSCE4350 - ER ? ? ? ? ?
  • 43. 05/17/17 43Yan Huang -CSCE4350 - ER ?
  • 44. 05/17/17 44Yan Huang -CSCE4350 - ER