Chapter 7: Entity-Relationship Model
Database System Concepts, 7th Ed.
©Silberschatz, Korth and Sudarshan�See www.db-book.com for conditions on re-use
Chapter 7: Entity-Relationship Model
©Silberschatz, Korth and Sudarshan
7.2
Database System Concepts
Design Phases
©Silberschatz, Korth and Sudarshan
7.3
Database System Concepts
Design Phases (Cont.)
The process of moving from an abstract data model to the implementation of the database proceeds in two final design phases.
©Silberschatz, Korth and Sudarshan
7.4
Database System Concepts
Design Approaches
©Silberschatz, Korth and Sudarshan
7.5
Database System Concepts
Outline of the ER Model
©Silberschatz, Korth and Sudarshan
7.6
Database System Concepts
ER model -- Database Modeling
©Silberschatz, Korth and Sudarshan
7.7
Database System Concepts
Entity Sets
instructor = (ID, name, street, city, salary )� course= (course_id, title, credits)
©Silberschatz, Korth and Sudarshan
7.8
Database System Concepts
Entity Sets -- instructor and student
instructor_ID instructor_name student-ID student_name
©Silberschatz, Korth and Sudarshan
7.9
Database System Concepts
Relationship Sets
Example:� 44553 (Peltier) advisor 22222 (Einstein) � student entity relationship set instructor entity
{(e1, e2, … en) | e1 ∈ E1, e2 ∈ E2, …, en ∈ En}��where (e1, e2, …, en) is a relationship
(44553,22222) ∈ advisor
©Silberschatz, Korth and Sudarshan
7.10
Database System Concepts
Relationship Set advisor
©Silberschatz, Korth and Sudarshan
7.11
Database System Concepts
Relationship Sets (Cont.)
©Silberschatz, Korth and Sudarshan
7.12
Database System Concepts
Degree of a Relationship Set
©Silberschatz, Korth and Sudarshan
7.13
Database System Concepts
Mapping Cardinality Constraints
©Silberschatz, Korth and Sudarshan
7.14
Database System Concepts
Mapping Cardinalities
One to one
One to many
Note: Some elements in A and B may not be mapped to any
elements in the other set
©Silberschatz, Korth and Sudarshan
7.15
Database System Concepts
Mapping Cardinalities
Many to one
Many to many
Note: Some elements in A and B may not be mapped to any
elements in the other set
©Silberschatz, Korth and Sudarshan
7.16
Database System Concepts
Complex Attributes
©Silberschatz, Korth and Sudarshan
7.17
Database System Concepts
Composite Attributes
©Silberschatz, Korth and Sudarshan
7.18
Database System Concepts
Redundant Attributes
©Silberschatz, Korth and Sudarshan
7.19
Database System Concepts
Weak Entity Sets
©Silberschatz, Korth and Sudarshan
7.20
Database System Concepts
Weak Entity Sets (Cont.)
©Silberschatz, Korth and Sudarshan
7.21
Database System Concepts
Weak Entity Sets (Cont.)
©Silberschatz, Korth and Sudarshan
7.22
Database System Concepts
E-R Diagrams
©Silberschatz, Korth and Sudarshan
7.23
Database System Concepts
Entity Sets
©Silberschatz, Korth and Sudarshan
7.24
Database System Concepts
Relationship Sets
©Silberschatz, Korth and Sudarshan
7.25
Database System Concepts
Relationship Sets with Attributes
©Silberschatz, Korth and Sudarshan
7.26
Database System Concepts
Roles
©Silberschatz, Korth and Sudarshan
7.27
Database System Concepts
Cardinality Constraints
©Silberschatz, Korth and Sudarshan
7.28
Database System Concepts
One-to-Many Relationship
©Silberschatz, Korth and Sudarshan
7.29
Database System Concepts
Many-to-One Relationships
©Silberschatz, Korth and Sudarshan
7.30
Database System Concepts
Many-to-Many Relationship
©Silberschatz, Korth and Sudarshan
7.31
Database System Concepts
Total and Partial Participation
participation of student in advisor relation is total
©Silberschatz, Korth and Sudarshan
7.32
Database System Concepts
Notation for Expressing More Complex Constraints
Instructor can advise 0 or more students. A student must have 1 advisor; cannot have multiple advisors
©Silberschatz, Korth and Sudarshan
7.33
Database System Concepts
Notation to Express Entity with Complex Attributes
©Silberschatz, Korth and Sudarshan
7.34
Database System Concepts
Expressing Weak Entity Sets
©Silberschatz, Korth and Sudarshan
7.35
Database System Concepts
E-R Diagram for a University Enterprise
©Silberschatz, Korth and Sudarshan
7.36
Database System Concepts
Reduction to Relation Schemas
©Silberschatz, Korth and Sudarshan
7.37
Database System Concepts
Reduction to Relation Schemas
©Silberschatz, Korth and Sudarshan
7.38
Database System Concepts
Representing Entity Sets
� student(ID, name, tot_cred)
� section ( course_id, sec_id, sem, year )
©Silberschatz, Korth and Sudarshan
7.39
Database System Concepts
Representing Relationship Sets
advisor = (s_id, i_id)
takes(c_id,s_id,grade)
©Silberschatz, Korth and Sudarshan
7.40
Database System Concepts
Representation of Entity Sets with Composite Attributes
©Silberschatz, Korth and Sudarshan
7.41
Database System Concepts
Representation of Entity Sets with Multivalued Attributes
©Silberschatz, Korth and Sudarshan
7.42
Database System Concepts
Redundancy of Schemas
©Silberschatz, Korth and Sudarshan
7.43
Database System Concepts
Redundancy of Schemas (Cont.)
©Silberschatz, Korth and Sudarshan
7.44
Database System Concepts
Redundancy of Schemas (Cont.)
©Silberschatz, Korth and Sudarshan
7.45
Database System Concepts
Advanced Topics
©Silberschatz, Korth and Sudarshan
7.46
Database System Concepts
Non-binary Relationship Sets
©Silberschatz, Korth and Sudarshan
7.47
Database System Concepts
Cardinality Constraints on Ternary Relationship
1. Each A entity is associated with a unique entity from B and C or
2. Each pair of entities from (A, B) is associated with a unique C entity, and each pair (A, C) is associated with a unique B
©Silberschatz, Korth and Sudarshan
7.48
Database System Concepts
Specialization
©Silberschatz, Korth and Sudarshan
7.49
Database System Concepts
Specialization Example
©Silberschatz, Korth and Sudarshan
7.50
Database System Concepts
Representing Specialization via Schemas
schema attributes
person ID, name, street, city
student ID, tot_cred
employee ID, salary
©Silberschatz, Korth and Sudarshan
7.51
Database System Concepts
Representing Specialization as Schemas (Cont.)
schema attributes
person ID, name, street, city
student ID, name, street, city, tot_cred
employee ID, name, street, city, salary
©Silberschatz, Korth and Sudarshan
7.52
Database System Concepts
Generalization
©Silberschatz, Korth and Sudarshan
7.53
Database System Concepts
Design Constraints on a Specialization/Generalization
©Silberschatz, Korth and Sudarshan
7.54
Database System Concepts
Aggregation
©Silberschatz, Korth and Sudarshan
7.55
Database System Concepts
Aggregation (Cont.)
©Silberschatz, Korth and Sudarshan
7.56
Database System Concepts
Aggregation (Cont.)
©Silberschatz, Korth and Sudarshan
7.57
Database System Concepts
Representing Aggregation via Schemas
eval_for (s_ID, project_id, i_ID, evaluation_id)
©Silberschatz, Korth and Sudarshan
7.58
Database System Concepts
Design Issues
©Silberschatz, Korth and Sudarshan
7.59
Database System Concepts
Entities vs. Attributes
©Silberschatz, Korth and Sudarshan
7.60
Database System Concepts
Entities vs. Relationship sets
Possible guideline is to designate a relationship set to describe an action that occurs between entities
For example, attribute date as attribute of advisor or as attribute of student
©Silberschatz, Korth and Sudarshan
7.61
Database System Concepts
Binary Vs. Non-Binary Relationships
©Silberschatz, Korth and Sudarshan
7.62
Database System Concepts
Converting Non-Binary Relationships to Binary Form
1. RA, relating E and A 2. RB, relating E and B � 3. RC, relating E and C
1. a new entity ei in the entity set E 2. add (ei , ai ) to RA
3. add (ei , bi ) to RB 4. add (ei , ci ) to RC
©Silberschatz, Korth and Sudarshan
7.63
Database System Concepts
Converting Non-Binary Relationships (Cont.)
©Silberschatz, Korth and Sudarshan
7.64
Database System Concepts
E-R Design Decisions
©Silberschatz, Korth and Sudarshan
7.65
Database System Concepts
Summary of Symbols Used in E-R Notation
©Silberschatz, Korth and Sudarshan
7.66
Database System Concepts
Symbols Used in E-R Notation (Cont.)
©Silberschatz, Korth and Sudarshan
7.67
Database System Concepts
Alternative ER Notations
©Silberschatz, Korth and Sudarshan
7.68
Database System Concepts
Alternative ER Notations
Chen IDE1FX (Crows feet notation)
©Silberschatz, Korth and Sudarshan
7.69
Database System Concepts
UML
©Silberschatz, Korth and Sudarshan
7.70
Database System Concepts
ER vs. UML Class Diagrams
*Note reversal of position in cardinality constraint depiction
©Silberschatz, Korth and Sudarshan
7.71
Database System Concepts
ER vs. UML Class Diagrams
ER Diagram Notation
Equivalent in UML
*Generalization can use merged or separate arrows independent
of disjoint/overlapping
©Silberschatz, Korth and Sudarshan
7.72
Database System Concepts
UML Class Diagrams (Cont.)
©Silberschatz, Korth and Sudarshan
7.73
Database System Concepts
End of Chapter 7�
Database System Concepts, 7th Ed.
©Silberschatz, Korth and Sudarshan�See www.db-book.com for conditions on re-use