advanced entity relationship concepts. advanced concepts uids intersection entities recursive...
TRANSCRIPT
Advanced Entity Relationship Concepts
Advanced Concepts
• UIDs• Intersection
Entities• Recursive
Relationships• Roles
• Subtypes• Exclusivity• Historical• Fan Traps• Non
transferability
Simple Unique IdentifierSimple Unique Identifier
CUSTOMER
# * customer num
Single attribute
Tag the UID with #
Compound UID - AttributesCompound UID - Attributes
MEMBERSHIP
# * num
# * start date
Multiple attributes
Members get a new membership each year but keep their membership number.
Compound UID - CompositeCompound UID - Composite
ACCOUNT
* num
BANK
# * num
Use a UID bar to indicate that a relationship is part of the entity’s UID
Use # to indicate that the attribute is part of the entity’s UID
What would you need to know to identifya specific instance of ACCOUNT?
#
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
Compound UID - RelationshipsCompound UID - Relationships
RENTAL ITEM
* rental period return dateo
RENTAL
# * transaction num * transaction date
COPY
# * inventory num * purchase cost
Multi-Level Relationship UIDs
Multi-Level Relationship UIDs
What would you need to know to identify a specific instance of TICKET?
VENUEPLAY
# * title
PERFORMANCE# * date# * time # * name
CUSTOMER
# * name
TICKET
* seat number
Multi-Level Relationship UIDs
Multi-Level Relationship UIDs
Venue name + Play title +
Performance date +
Performance time +
Customer name
VENUEPLAY
# * title
PERFORMANCE# * date# * time # * name
CUSTOMER
# * name
TICKET
* seat number
Multiple UIDsMultiple UIDs
badge num
payroll num
first and last name
EMPLOYEE
badge num
payroll num
last name
first name
#(1)*
#(3) *
#(2) *
#(2) *
Composition of a UID
SUPPLIER# CODE
PERSON# NAME# DATE OF BIRTH
• Example AExample A
SUPPLIER TITLE
SUPPLIER TITLEdistributor distributor ofof
distributed distributed byby
available asavailable as
forfor
• Example BExample B
RENTAL ITEM RENTALpart ofpart of
composedcomposedofof
# LINE NO
• Example CExample C
Primary 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.
RENTAL ITEM
* rental period return dateo
RENTAL
# * transaction num * transaction date
COPY
# * inventory num * purchase cost
RENTAL
# * transaction num * transaction date
COPY
# * inventory num * purchase cost
Intersection Entity
Note how Crows’ Feet Change!
Intersection Entities:Identifying the Problem
Intersection Entities:Identifying the Problem
TITLE SUPPLIER
supplied by
supplier of
In which entity would you store the attribute: purchase price?
# * prod code * name
# * supplier no * name
Intersection EntitiesIntersection EntitiesCATALOG ITEM
available as
SUPPLIER
supplier of
TITLE
TITLE
# * prod code * name
# * supplier no * name
* purchase price
forfor
Unique IdentifiersUnique Identifiers
available as
CATALOG ITEM
SUPPLIER
supplier of
TITLE
TITLE
# * prod code * name
# * supplier no * name
* purchase price
forfor
CATALOG ITEM
available as
SUPPLIER
supplier of
TITLE
TITLE
# * prod code * name
# * supplier no * name
# * item num * purchase price
forforOR
Modeling Recursive Relationships
Modeling Recursive Relationships
...and mine
...he’s mymanager
...but I’m HISmanager!
EMPLOYEE
manager of
managed by
Modeling Hierarchical DataModeling Hierarchical Data
Company
Division
Team
Department
TEAM# name
DEPARTMENT# * name
DIVISION
# * name
COMPANY# * name
Hierarchies as Recursive Relationships
Hierarchies as Recursive Relationships
ORGANIZATIONELEMENT
made up of
within# * name * type
TEAM# name
DEPARTMENT# * name
DIVISION
# * name
COMPANY# * name
Network StructuresNetwork Structures
COMPONENT
# * identifier
a part of
made up of
Network StructuresNetwork Structures
COMPONENT
# * identifier
a part of
made up of
COMPONENT COMPONENT
made up of
a part of # * identifier# * identifier
Network StructuresNetwork Structures
COMPONENT COMPONENT
made up of
a part of # * identifier# * identifier
ASSEMBLY RULE
COMPONENT
# * identifier
COMPONENT
# * identifier
made up of
a part of
forfor
o quantity
Network StructuresNetwork Structures
COMPONENT
ASSEMBLYRULE
a part ofmade up of
for for
o quantity
# * identifier
Identifying RolesIdentifying RolesENROLLMENT
STUDENT
COURSE SECTION
INSTRUCTOR
for for
included in
taken by
taught by
theteacher of
* date enrolled* fee
# * id * name
* location * start date
# * id * name * salary
COURSE
# * code * name
for
the subjectof
Modeling RolesModeling Roles
for
for
enrolled onENROLLMENT
* date enrolled
COURSE
# * code * name
PERSON# * id * name o salary * fee
taught by
for
COURSE SECTION * location * start date
taken by
theteacher of
included in
SubtypesSubtypes
* category* durationO audio
TITLE
#
**
product code title description
*
GAMEMOVIE
* category* medium* minimum memory
All titles are either movies or games
Creating a SubtypeIn ERD:In ERD:
Drag and drop.Drag and drop.oror
Draw new Draw new entity fully entity fully within or within or around the around the other.other.
In RON:
Set Property Set Property Type ofType of..
or
Drag and drop.Drag and drop. andSelect association for Select association for dropped entity.dropped entity.
Select Associations
Type ofSub Entities
Exclusive EntitiesExclusive Entities
COMPANY
id name telephone num supplier num sales contact
#*
o
*
*
o
COPYacquired from
the source of
the holder of
held byMEMBERSHIP
* num* start date* expiry date termination
#
* inventory numo condition
oCompany in two roles
Splitting EntitiesSplitting EntitiesCOMPANY
#
**
acquired from
the source of
the holder of
held by
id name telephone num
*
OTHER
supplier num sales contact
*SUPPLIER
MEMBERSHIP
* num* start date* expiry date termination
#
COPY
* inventory numo condition
o
Could teacher-student-person be so modeled?
Nesting EntitiesNesting Entities
EMPLOYEE
SALES
REP
TELESALES
CLERICAL
HUMANRESOURCES
CAR
driven by
authorizedto drive
Business Rule: only sales reps can drive company cars
Nesting EntitiesNesting EntitiesAIRCRAFT
AIRPLANE
GLIDER
POWERED AIRPLANE
PROP PLANE
JET PLANE
HELICOPTER HOVERCRAFTOTHERAIRCRAFT
Recursive SubtypesRecursive Subtypes
ORGANIZATIONELEMENTTYPE
ORGANIZATION ELEMENT
made up of
ORGANIZATION
SUBDIVISION within
of
the classificationfor
Modeling Exclusive Relationships
Modeling Exclusive Relationships
o
oMEMBERSHIP
COMPANY
CUSTOMER
the holder of
held by
held by
the holder of
* num* start date* expiry dateo termination
* name* postal area0 contact name
* num* first name* last name
Creating an Arc Creating an Arc
CATALOG
PUBLICATION
REVIEW
in
of
of
in
Modeling ExclusivityModeling Exclusivity“We offer membership to individual customers and companies”
MEMBERSHIP
CUSTOMER COMPANY
MEMBERSHIP
CUSTOMER COMPANY
MEMBERSHIP
CUSTOMER COMPANY
MEMBER
INDIVIDUAL ORGANIZATION
Modeling Data over TimeModeling Data over Time
APARTMENT
# * code * address
PERSON
# * id * last name * first name
rented by
the renter of
What if you need to hold an apartment’s rental history?
Modeling Data over TimeModeling Data over Time
APARTMENT
# * code * address
PERSON
# * id * last name * first name
rented by
RENTAL HISTORY
for
the renter of
for
# * from date to dateo
Modeling Data over TimeModeling Data over Time
the employer
of
employedby COMPANY
# * code * name
# * id last name*
* first name
MEMBER
Modeling Data over TimeModeling Data over Time
COMPANY
# * code * name
# * id last name*
* first name
MEMBER
# * from date to dateo
EMPLOYMENTHISTORY ENTRY
for for
employedby
the employer
of
Fan TrapsFan Traps
PERSON POSITION
COMPANY
# * id * last name * first name
# * job title job descriptiono
# * code * name
the holder of
held by
included in
the employer of
the employer of
employed by
Fan TrapsFan TrapsPERSON POSITION
COMPANY
# * id * last name * first name
# * job title job descriptiono
# * code * name
employed as
held bythe subject of
the employer for
the employer for
employed at
POSITION HISTORY
ORGANIZATIONHISTORY
COMPANY HISTORY
for
for
for
forfor
for
* start date end dateo
* start date end dateo
* start date end dateo
Resolving Fan TrapsResolving Fan Traps
PERSONPOSITION
COMPANY
# * id * last name * first name
# * job title job descriptiono
# * code * name
the employer for
for
EMPLOYMENT HISTORY
a party to
at
as
included in
* start date end dateo
#
Transferable RelationshipsTransferable Relationships
DEPARTMENT
# * code
PERSON
# * id * last name * first name
works in
employs
Personnel Finance Sales
Head office
Non-Transferable Relationships
Non-Transferable RelationshipsCOMPANY
#
**acquired from
the source of
id name telephone num
supplier num sales contact
**
SUPPLIERCOPY
* inventory numo condition
OTHER
*