advanced entity relationship concepts. advanced concepts uids intersection entities recursive...

43
Advanced Entity Relationship Concepts

Upload: clement-rose

Post on 26-Dec-2015

228 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Advanced Entity Relationship Concepts. Advanced Concepts UIDs Intersection Entities Recursive Relationships Roles Subtypes Exclusivity Historical Fan

Advanced Entity Relationship Concepts

Page 2: Advanced Entity Relationship Concepts. Advanced Concepts UIDs Intersection Entities Recursive Relationships Roles Subtypes Exclusivity Historical Fan

Advanced Concepts

• UIDs• Intersection

Entities• Recursive

Relationships• Roles

• Subtypes• Exclusivity• Historical• Fan Traps• Non

transferability

Page 3: Advanced Entity Relationship Concepts. Advanced Concepts UIDs Intersection Entities Recursive Relationships Roles Subtypes Exclusivity Historical Fan

Simple Unique IdentifierSimple Unique Identifier

CUSTOMER

# * customer num

Single attribute

Tag the UID with #

Page 4: Advanced Entity Relationship Concepts. Advanced Concepts UIDs Intersection Entities Recursive Relationships Roles Subtypes Exclusivity Historical Fan

Compound UID - AttributesCompound UID - Attributes

MEMBERSHIP

# * num

# * start date

Multiple attributes

Members get a new membership each year but keep their membership number.

Page 5: Advanced Entity Relationship Concepts. Advanced Concepts UIDs Intersection Entities Recursive Relationships Roles Subtypes Exclusivity Historical Fan

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?

#

Page 6: Advanced Entity Relationship Concepts. Advanced Concepts UIDs Intersection Entities Recursive Relationships Roles Subtypes Exclusivity Historical Fan

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

Page 7: Advanced Entity Relationship Concepts. Advanced Concepts UIDs Intersection Entities Recursive Relationships Roles Subtypes Exclusivity Historical Fan

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

Page 8: Advanced Entity Relationship Concepts. Advanced Concepts UIDs Intersection Entities Recursive Relationships Roles Subtypes Exclusivity Historical Fan

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

Page 9: Advanced Entity Relationship Concepts. Advanced Concepts UIDs Intersection Entities Recursive Relationships Roles Subtypes Exclusivity Historical Fan

Multiple UIDsMultiple UIDs

badge num

payroll num

first and last name

EMPLOYEE

badge num

payroll num

last name

first name

#(1)*

#(3) *

#(2) *

#(2) *

Page 10: Advanced Entity Relationship Concepts. Advanced Concepts UIDs Intersection Entities Recursive Relationships Roles Subtypes Exclusivity Historical Fan

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

Page 11: Advanced Entity Relationship Concepts. Advanced Concepts UIDs Intersection Entities Recursive Relationships Roles Subtypes Exclusivity Historical Fan

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.

Page 12: Advanced Entity Relationship Concepts. Advanced Concepts UIDs Intersection Entities Recursive Relationships Roles Subtypes Exclusivity Historical Fan

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!

Page 13: Advanced Entity Relationship Concepts. Advanced Concepts UIDs Intersection Entities Recursive Relationships Roles Subtypes Exclusivity Historical Fan

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

Page 14: Advanced Entity Relationship Concepts. Advanced Concepts UIDs Intersection Entities Recursive Relationships Roles Subtypes Exclusivity Historical Fan

Intersection EntitiesIntersection EntitiesCATALOG ITEM

available as

SUPPLIER

supplier of

TITLE

TITLE

# * prod code * name

# * supplier no * name

* purchase price

forfor

Page 15: Advanced Entity Relationship Concepts. Advanced Concepts UIDs Intersection Entities Recursive Relationships Roles Subtypes Exclusivity Historical Fan

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

Page 16: Advanced Entity Relationship Concepts. Advanced Concepts UIDs Intersection Entities Recursive Relationships Roles Subtypes Exclusivity Historical Fan

Modeling Recursive Relationships

Modeling Recursive Relationships

...and mine

...he’s mymanager

...but I’m HISmanager!

EMPLOYEE

manager of

managed by

Page 17: Advanced Entity Relationship Concepts. Advanced Concepts UIDs Intersection Entities Recursive Relationships Roles Subtypes Exclusivity Historical Fan

Modeling Hierarchical DataModeling Hierarchical Data

Company

Division

Team

Department

TEAM# name

DEPARTMENT# * name

DIVISION

# * name

COMPANY# * name

Page 18: Advanced Entity Relationship Concepts. Advanced Concepts UIDs Intersection Entities Recursive Relationships Roles Subtypes Exclusivity Historical Fan

Hierarchies as Recursive Relationships

Hierarchies as Recursive Relationships

ORGANIZATIONELEMENT

made up of

within# * name * type

TEAM# name

DEPARTMENT# * name

DIVISION

# * name

COMPANY# * name

Page 19: Advanced Entity Relationship Concepts. Advanced Concepts UIDs Intersection Entities Recursive Relationships Roles Subtypes Exclusivity Historical Fan

Network StructuresNetwork Structures

COMPONENT

# * identifier

a part of

made up of

Page 20: Advanced Entity Relationship Concepts. Advanced Concepts UIDs Intersection Entities Recursive Relationships Roles Subtypes Exclusivity Historical Fan

Network StructuresNetwork Structures

COMPONENT

# * identifier

a part of

made up of

COMPONENT COMPONENT

made up of

a part of # * identifier# * identifier

Page 21: Advanced Entity Relationship Concepts. Advanced Concepts UIDs Intersection Entities Recursive Relationships Roles Subtypes Exclusivity Historical Fan

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

Page 22: Advanced Entity Relationship Concepts. Advanced Concepts UIDs Intersection Entities Recursive Relationships Roles Subtypes Exclusivity Historical Fan

Network StructuresNetwork Structures

COMPONENT

ASSEMBLYRULE

a part ofmade up of

for for

o quantity

# * identifier

Page 23: Advanced Entity Relationship Concepts. Advanced Concepts UIDs Intersection Entities Recursive Relationships Roles Subtypes Exclusivity Historical Fan

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

Page 24: Advanced Entity Relationship Concepts. Advanced Concepts UIDs Intersection Entities Recursive Relationships Roles Subtypes Exclusivity Historical Fan

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

Page 25: Advanced Entity Relationship Concepts. Advanced Concepts UIDs Intersection Entities Recursive Relationships Roles Subtypes Exclusivity Historical Fan

SubtypesSubtypes

* category* durationO audio

TITLE

#

**

product code title description

*

GAMEMOVIE

* category* medium* minimum memory

All titles are either movies or games

Page 26: Advanced Entity Relationship Concepts. Advanced Concepts UIDs Intersection Entities Recursive Relationships Roles Subtypes Exclusivity Historical Fan

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

Page 27: Advanced Entity Relationship Concepts. Advanced Concepts UIDs Intersection Entities Recursive Relationships Roles Subtypes Exclusivity Historical Fan

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

Page 28: Advanced Entity Relationship Concepts. Advanced Concepts UIDs Intersection Entities Recursive Relationships Roles Subtypes Exclusivity Historical Fan

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?

Page 29: Advanced Entity Relationship Concepts. Advanced Concepts UIDs Intersection Entities Recursive Relationships Roles Subtypes Exclusivity Historical Fan

Nesting EntitiesNesting Entities

EMPLOYEE

SALES

REP

TELESALES

CLERICAL

HUMANRESOURCES

CAR

driven by

authorizedto drive

Business Rule: only sales reps can drive company cars

Page 30: Advanced Entity Relationship Concepts. Advanced Concepts UIDs Intersection Entities Recursive Relationships Roles Subtypes Exclusivity Historical Fan

Nesting EntitiesNesting EntitiesAIRCRAFT

AIRPLANE

GLIDER

POWERED AIRPLANE

PROP PLANE

JET PLANE

HELICOPTER HOVERCRAFTOTHERAIRCRAFT

Page 31: Advanced Entity Relationship Concepts. Advanced Concepts UIDs Intersection Entities Recursive Relationships Roles Subtypes Exclusivity Historical Fan

Recursive SubtypesRecursive Subtypes

ORGANIZATIONELEMENTTYPE

ORGANIZATION ELEMENT

made up of

ORGANIZATION

SUBDIVISION within

of

the classificationfor

Page 32: Advanced Entity Relationship Concepts. Advanced Concepts UIDs Intersection Entities Recursive Relationships Roles Subtypes Exclusivity Historical Fan

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

Page 33: Advanced Entity Relationship Concepts. Advanced Concepts UIDs Intersection Entities Recursive Relationships Roles Subtypes Exclusivity Historical Fan

Creating an Arc Creating an Arc

CATALOG

PUBLICATION

REVIEW

in

of

of

in

Page 34: Advanced Entity Relationship Concepts. Advanced Concepts UIDs Intersection Entities Recursive Relationships Roles Subtypes Exclusivity Historical Fan

Modeling ExclusivityModeling Exclusivity“We offer membership to individual customers and companies”

MEMBERSHIP

CUSTOMER COMPANY

MEMBERSHIP

CUSTOMER COMPANY

MEMBERSHIP

CUSTOMER COMPANY

MEMBER

INDIVIDUAL ORGANIZATION

Page 35: Advanced Entity Relationship Concepts. Advanced Concepts UIDs Intersection Entities Recursive Relationships Roles Subtypes Exclusivity Historical Fan

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?

Page 36: Advanced Entity Relationship Concepts. Advanced Concepts UIDs Intersection Entities Recursive Relationships Roles Subtypes Exclusivity Historical Fan

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

Page 37: Advanced Entity Relationship Concepts. Advanced Concepts UIDs Intersection Entities Recursive Relationships Roles Subtypes Exclusivity Historical Fan

Modeling Data over TimeModeling Data over Time

the employer

of

employedby COMPANY

# * code * name

# * id last name*

* first name

MEMBER

Page 38: Advanced Entity Relationship Concepts. Advanced Concepts UIDs Intersection Entities Recursive Relationships Roles Subtypes Exclusivity Historical Fan

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

Page 39: Advanced Entity Relationship Concepts. Advanced Concepts UIDs Intersection Entities Recursive Relationships Roles Subtypes Exclusivity Historical Fan

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

Page 40: Advanced Entity Relationship Concepts. Advanced Concepts UIDs Intersection Entities Recursive Relationships Roles Subtypes Exclusivity Historical Fan

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

Page 41: Advanced Entity Relationship Concepts. Advanced Concepts UIDs Intersection Entities Recursive Relationships Roles Subtypes Exclusivity Historical Fan

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

#

Page 42: Advanced Entity Relationship Concepts. Advanced Concepts UIDs Intersection Entities Recursive Relationships Roles Subtypes Exclusivity Historical Fan

Transferable RelationshipsTransferable Relationships

DEPARTMENT

# * code

PERSON

# * id * last name * first name

works in

employs

Personnel Finance Sales

Head office

Page 43: Advanced Entity Relationship Concepts. Advanced Concepts UIDs Intersection Entities Recursive Relationships Roles Subtypes Exclusivity Historical Fan

Non-Transferable Relationships

Non-Transferable RelationshipsCOMPANY

#

**acquired from

the source of

id name telephone num

supplier num sales contact

**

SUPPLIERCOPY

* inventory numo condition

OTHER

*