Professional Documents
Culture Documents
Data Bases
Data Bases
Entity--Relationship
Entity
Instructor: Reza Godaz
Azad University of Mashhad
Database System
y
Concepts,
p , 5th Ed.
Silberschatz, Korth and Sudarshan
See www.db-book.com for conditions on re-use
Database System Concepts - 5th Edition, Oct 5, 2006
6.1
:6 Entity--Relationship
Entity
E-R
E
R
) (Weak Entity Sets
ER-R ) (Extended E-R
UML
6.2
:
:
z
)
:
(.
: E-R
.
: functional .
:
z
) ( E-R ) (
:
6.3
ER ) (entities
) (relationships
.
z :
) (attributes
z : .
) (entity set .
z .
6.4
loan customer
customer_id customer_ customer_ customer_
name street
city
6.5
loan_
number
amount
.( relationship )
:
A-102
account entity
depositor
relationship set
Hayes
customer entity
n 2
.
{(e1, e2, en) | e1 E1, e2 E2, , en En}
.( e1, e2, , en)
:
z
(Hayes, A-102) depositor
6.6
borrower
6.7
)(
) (attribute .
customer account
depositor
access-date .
6.8
.
) 2 (
.
.
.
:
3 . 3
employee job branch )
(.
(
6.9
)(Attributes
.
:
customer = (customer_id, customer_name,
customer_street,
t
t t customer_city
t
) it
) loan = (loan_number, amount
) : (Domain .
:
z
) (Simple ) . (composite
- ) (Single-valued - )(multi-valued
- phone_numbers :
z (Derived attributes) :
age date_of_birth .
Silberschatz, Korth and Sudarshan
6.10
6.11
)(Mapping Cardinality Constraints
.
.
:
z
z
z
z
6.12
.
A B
:
Silberschatz, Korth and Sudarshan
6.13
.
A B
:
Silberschatz, Korth and Sudarshan
6.14
)(Keys
) (super key
.
) (candidate key
.
z
Customer_id customer.
account_number account.
) (primary key
.
6.15
.
z ) (customer_id, account_number depositor.
z :
.
access_dates account customer
.
.
6.16
E-R
.
.
.
.
z
z .
.
Silberschatz, Korth and Sudarshan
6.17
E-R
6.18
6.19
)(Roles
) (
worker
manager k
employee works_for
.
E-R
.
6.20
Cardinality
)( 1 ) (one, )(
(many.
) many,
--:
z borrower .
z borrower .
6.21
(One
One--To - )To-Many
) ( borrower
) ( borrower
.
6.22
(Many
Many--To -- )To-One
) ( borrower
borrower .
6.23
(Many
Many--To
-- )To--Many
) ( borrower
borrower
b
(
)
6.24
) : (
.
:
.
z borrower customer
.
6.25
) --
loan customer (borrower
6.26
E-R
6.27
works_on job
) (.
:
z R A B C B C .
:
.1 A B C
.2 ) (A, B C ) (A, C
.
B
z
z .
6.28
) (
.
) 15-6 ( 74 emploee
emp_name
emp name
(...
.
)
(
(
.
.
) (34
6.29
) (parentt
z
.
-
) .
(
z
) (works_on
6.30
R A B C E RA
RB RC
E ) ei identifying attribute (
z
.1
) (ai , bi , ci R :
ei E
.2
) (ei , ai RA .
.3
) (ei , bi RB .
.4
) ((ei , ci RC .
6.31
)(
:
.
z
z R
.
: RA RB RC
A B C .
z identifying attribute E
.
6.32
ER
access-date account
account
z .
z :
. access-date
) account ( .
).
(
6.33
Database System
y
Concepts,
p , 5th Ed.
Silberschatz, Korth and Sudarshan
See www.db-book.com for conditions on re-use
Database System Concepts - 5th Edition, Oct 5, 2006
6.34
)(Weak Entity Sets
.
)
) (identifying entity set
(
.
z
.
.
) discriminator (partial key
.
discriminator
6.35
)(
underline
d li
) (payment_number
payment )(loan_number, payment_number
.
6.36
)(
:
.
strong
payment
loan_number
loan number
) ( payment loan
loan_number payment loan
.
6.37
) course (
) course_offering (
.
.
) semester course_offering ( ) section_number
( .
course_offering
course offering
course_number .
course course_number
.
6.38
: E-R
)(Specialization
(
)
.
. .
ISA.
( customer is
is a
) a person
) : (Attribute inheritance
.
6.39
Specialization
6.40
: E-R)(Generalization
:
.
ER
.
6.41
( )Generalization Specialization
.
( permanent_employee )
teller secretary officer ( permanent_employee )
:
temporary_employee, permanent_employee z
teller secretary officer
z
. superclass subclass ISA
6.42
Specialization/Generalization
p
:
z )(condition-defined
: 65
. senior-citizen ISA
senior-citizen S person
z )(user-defined
:
z )(Disjoint
.
disjoint ISA
E-R
E R
z )(Overlapping
.
6.43
) Specialization/Generalization(
: (Completeness
C
l t
constraint
) t i t
.
::
z ) :(total
.
z ) :(partial
.
6.44
(Aggregation
))Aggregation
works_on
.
manages job branch
emploee.
works_on manages
works on
job branch emploee .
6.45
)(
works_on manages overlap.
works_on.
k
manages
z
z works_on manages).
(
works_on .
.
z .
z .
:
z
z branch jjob emploee .
6.46
6.47
E-R
.
.
.
specialization/generalization
p
g
modularity
.
aggregation
) (
6.48
ER
6.49
How
H
about
b t doing
d i another
th ER design
d i
interactively on the board?
Database System
y
Concepts,
p , 5th Ed.
Silberschatz, Korth and Sudarshan
See www.db-book.com for conditions on re-use
Database System Concepts - 5th Edition, Oct 5, 2006
6.50
ER
6.51
()ER
6.52
ER .
.
) (
.
6.53
.
= payment
) ( loan_number, payment_number, payment_date, payment_amount
6.54
.
: : borrower
) borrower = (customer_id, loan_number
6.55
: account_branch
branch_name account .
6.56
)(
.
z
.
.
.
z : payment loan_payment
) loan_number ( payment_number
6.57
(Composite
p
))and Multivalued Attributes
.
z : customer name first_name
last_name
name.last_name.
name.first_name name last name
name first name
M E EM .
z EM E M
.
z : dependent_names employee
:
)employee_dependent_names = ( employee_id, dname
EM
z
.
: employee 123-45-6789 Jack
Jane ) (123-45-6789 , Jack
) (123-45-6789 , Jane .
Silberschatz, Korth and Sudarshan
6.58
5th
Specialization
p
:1
z
z
.:
attributes
name street,
name,
street city
name, credit_rating
name, salary
schema
person
customer
employee
z : employee
.
6.59
)(
Specialization
) :2 disjoint total(
z
.
attributes
name, street, city
name, street, city, credit_rating
name, street, city, salary
schema
person
customer
employee
(p
g )person
z total generalized
.
view .
.
z street : city customer employee
.
6.60
z
z
.
6.61
)(
: manages works_on
manager :
)manages (employee_id, branch_name, title, manager_name
works_on
works on
manager_name manages .
6.62
UML
UML: Unified Modeling Language
UML h
has many components
t tto graphically
hi ll model
d l diff
differentt aspects
t off an
differences.
6.63
6.64
connecting the entity sets. The relationship set name is written adjacent
to the line.
line
The role played by an entity set in a relationship set may also be
specified by writing the role name on the line, adjacent to the entity set.
The relationship set name may alternatively be written in a box, along
with attributes of the relationship set, and the box is connected, using a
dotted line, to the line depicting
p
g the relationship
p set.
6.65
overlapping
disjoint
6.66
6.67
End of Chapter 6
Database System
y
Concepts,
p , 5th Ed.
Silberschatz, Korth and Sudarshan
See www.db-book.com for conditions on re-use
Database System Concepts - 5th Edition, Oct 5, 2006
6.68
6.69
6.70
6.71
6.72
Existence Dependencies
If the existence of entity x depends on the existence of entity y,
loan
loan-payment
payment
If a loan entity
y is deleted,, then all its associated p
payment
y
entities
must be deleted also.
6.73
Figure 6.8
6.74
Figure 6.15
6.75
Figure 6.16
6.76
Figure 6.26
6.77
Figure 6.27
6.78
Figure 6.28
6.79
Figure 6.29
6.80
Figure 6.30
6.81
Figure 6.31
6.82
Alternative E
E--R Notations
Figure
Fi
6.24
6.83