Title: Advanced Entity Relationship Concepts
1Advanced Entity Relationship Concepts
2Advanced Concepts
- UIDs
- Intersection Entities
- Recursive Relationships
- Roles
- Subtypes
- Exclusivity
- Historical
- Fan Traps
- Non transferability
3Simple Unique Identifier
CUSTOMER
customer num
Single attribute
Tag the UID with
4Compound UID - Attributes
Members get a new membership each year but keep
their membership number.
MEMBERSHIP
num
start date
Multiple attributes
5Compound UID - Composite
What would you need to know to identify a
specific instance of ACCOUNT?
ACCOUNT
BANK
num
num
Use a UID bar to indicate that a relationship is
part of the entitys UID
Use to indicate that the attribute is part of
the entitys UID
6Compound UID - Relationships
RENTAL ITEM
What do you need to know to identify a specific
instance of RENTAL ITEM?
Rental item requires the rental transaction num
and the inventory num
rental period return date
o
RENTAL
COPY
transaction num transaction date
inventory num purchase cost
7Multi-Level Relationship UIDs
PERFORMANCE
PLAY
VENUE
date time
name
title
CUSTOMER
name
What would you need to know to identify a
specific instance of TICKET?
8Multi-Level Relationship UIDs
PERFORMANCE
PLAY
VENUE
date time
name
title
Venue name Play title Performance date
Performance time Customer name
CUSTOMER
name
9Multiple UIDs
badge num
EMPLOYEE
(1)
badge num
payroll num
(2)
first name
(2)
last name
(3)
payroll num
first and last name
10Composition of a UID
11Primary Unique Identifier
- An entity can have several unique identifiers.
- One may be appointed as the primary unique
identifier. - Only the Primary UID is shown in the entity
relationship diagram.
12Intersection Entity
Note how Crows Feet Change!
13Intersection EntitiesIdentifying the Problem
supplier of
TITLE
SUPPLIER
prod code name
supplier no name
supplied by
In which entity would you store the attribute
purchase price?
14Intersection Entities
CATALOG ITEM
purchase price
for
for
available as
supplier of
SUPPLIER
TITLE
TITLE
prod code name
supplier no name
15Unique Identifiers
CATALOG ITEM
CATALOG ITEM
purchase price
item num purchase price
OR
for
for
for
for
available as
supplier of
available as
supplier of
SUPPLIER
SUPPLIER
TITLE
TITLE
prod code name
prod code name
supplier no name
supplier no name
TITLE
TITLE
16Modeling Recursive Relationships
...but Im HIS manager!
...and mine
...hes my manager
17Modeling Hierarchical Data
Company
Division
Department
Team
18Hierarchies as Recursive Relationships
TEAM
name
made up of
DEPARTMENT
name
ORGANIZATIONELEMENT
name type
DIVISION
within
name
COMPANY
name
19Network Structures
a part of
COMPONENT
identifier
made up of
20Network Structures
a part of
COMPONENT
identifier
made up of
made up of
COMPONENT
COMPONENT
identifier
identifier
a part of
21Network Structures
ASSEMBLY RULE
o quantity
for
for
made up of
a part of
COMPONENT
COMPONENT
identifier
identifier
made up of
COMPONENT
COMPONENT
identifier
identifier
a part of
22Network Structures
ASSEMBLYRULE
o quantity
for
for
made up of
a part of
COMPONENT
identifier
23Identifying Roles
ENROLLMENT
date enrolled fee
for
for
taken by
included in
INSTRUCTOR
taught by
COURSE SECTION
id name salary
STUDENT
the teacher of
id name
location start date
for
COURSE
code name
the subject of
24Modeling Roles
enrolled on
PERSON
ENROLLMENT
id name o salary
date enrolled
fee
for
the teacher of
for
taught by
taken by
COURSE
for
COURSE SECTION
code name
location start date
included in
25Subtypes
TITLE
product code title description
MOVIE
GAME
category duration O audio
category medium minimum memory
All titles are either movies or games
26Creating a Subtype
- In ERD
- Drag and drop.
- or
- Draw new entity fully within or around the other.
27Exclusive Entities
COPY
COMPANY
acquired from
inventory num o condition
the source of
id name telephone num supplier num sales
contact
o
held by
o
the holder of
o
Company in two roles
28Splitting Entities
COMPANY
id name telephone num
held by
the holder of
o
Could teacher-student-person be so modeled?
29Nesting Entities
Business Rule only sales reps can drive company
cars
CAR
30Nesting Entities
AIRCRAFT
AIRPLANE
POWERED AIRPLANE
PROP PLANE
GLIDER
JET PLANE
OTHER AIRCRAFT
HELICOPTER
HOVERCRAFT
31Recursive Subtypes
ORGANIZATION ELEMENT
of
ORGANIZATION
the classification for
within
SUBDIVISION
made up of
32Modeling Exclusive Relationships
COMPANY
name postal area 0 contact name
held by
the holder of
o
MEMBERSHIP
num start date expiry date o termination
CUSTOMER
the holder of
o
num first name last name
held by
33Creating an Arc
PUBLICATION
CATALOG
REVIEW
34Modeling Exclusivity
We offer membership to individual customers and
companies
MEMBERSHIP
MEMBERSHIP
INDIVIDUAL
ORGANIZATION
MEMBERSHIP
CUSTOMER
COMPANY
CUSTOMER
COMPANY
MEMBER
CUSTOMER
COMPANY
35Modeling Data over Time
What if you need to hold an apartments rental
history?
PERSON
APARTMENT
rented by
id last name first name
code address
the renter of
36Modeling Data over Time
PERSON
for
RENTAL HISTORY
id last name first name
from date to date
the renter of
o
for
rented by
APARTMENT
code address
37Modeling Data over Time
employed by
COMPANY
the employer of
code name
38Modeling Data over Time
EMPLOYMENTHISTORY ENTRY
from date to date
o
for
for
the employer of
employed by
39Fan Traps
PERSON
POSITION
the holder of
id last name first name
job title job description
o
held by
employed by
included in
COMPANY
code name
the employer of
the employer of
40Fan Traps
POSITION HISTORY
POSITION
employed as
PERSON
for
job title job description
id last name first name
o
held by
for
the subject of
employed at
for
for
ORGANIZATIONHISTORY
COMPANY HISTORY
for
for
COMPANY
the employer for
code name
the employer for
41Resolving Fan Traps
COMPANY
EMPLOYMENT HISTORY
at
code name
the employer for
as
for
a party to
POSITION
PERSON
included in
job title job description
o
id last name first name
42Transferable Relationships
PERSON
works in
DEPARTMENT
id last name first name
code
employs
Head office
Personnel
Finance
Sales
43Non-Transferable Relationships
COMPANY
id name telephone num
acquired from
COPY
SUPPLIER
inventory num o condition
supplier num sales contact
the source of
OTHER