Database Management COP4540, SCS, FIU Enhanced Entity-Relationship and Object Modeling Chapter 4.

Post on 05-Jan-2016

217 views 0 download

Transcript of Database Management COP4540, SCS, FIU Enhanced Entity-Relationship and Object Modeling Chapter 4.

Database ManagementCOP4540, SCS, FIU

Enhanced Entity-Relationship and Object Modeling

Chapter 4

Database ManagementCOP4540, SCS, FIU

Supertypes and Subtypes

• Subtype: A subgrouping of the entities in an entity type that has distinct attributes

• Supertype: An entity type whose subtypes share common attributes

Database ManagementCOP4540, SCS, FIU

Employee supertype with three subtypes

EMPLOYEE

Name Address

Date_hiredSSN

HOURLYEMPLOYEE

SALAREDEMPLOYEE CONSULTANT

Hourly_rate Annual_salary Stock_option Contract_No. Billing_rate

Database ManagementCOP4540, SCS, FIU

Attribute Inheritance

• Subtype entities inherit values of all attributes of the supertype

• An occurrence of a subtype is also an occurrence of the supertype

• All common attributes of subtypes appear in the supertype

Database ManagementCOP4540, SCS, FIU

Use of Supertype/Subtype

• There are attributes that apply to some (but not all) of the instances of an entity.

• The instances of a subtype participate in a relationship unique to that subtype.

Database ManagementCOP4540, SCS, FIU

Unique relationship for a subtype

PATIENT

IDAdmit_date

Is_cared_forRESPONSIBLE

PHYSICIAN

Physician_ID

OUTPATIENTRESIDENTPATIENT

Checkback_dateDate_discharged

BED

Bed_ID

Is_assigned1 1

1N

Database ManagementCOP4540, SCS, FIU

Generalization and Specialization

• Generalization: The process of defining a more general entity from a set of more specialized entities.

• Specialization: The process of defining one or more subtypes of the supertype.

• Top-down conceptual refinement process.

• Bottom-up conceptual synthesis.

Database ManagementCOP4540, SCS, FIU

Example of generalization(a) Three entity types: CAR, TRUCK, and MOTORCYCLE

CARPrice

VIN Name

Make Model

No_of_Passengers

EngineDisplacement

MOTORCYCLEPrice

VIN Name

Make Model

EngineDisplacement

Year

Year

TRUCKPrice

VIN Name

Make Model

Capacity

EngineDisplacement

Year

Cab_type

Database ManagementCOP4540, SCS, FIU

VEHICLEPrice

VIN Name

Make Model

EngineDisplacement

Year

CARNo_of_Passengers

TRUCK Capacity

Cab_type

(b) Generalization to VEHICLE supertype

Database ManagementCOP4540, SCS, FIU

Example of specialization

PART

Unit_price

Description

Part_No

Qty_on_hand Location

Routing_number

Supplier_ID

(a) Entity type PART

Database ManagementCOP4540, SCS, FIU

(b) Specialization to MANUFACTURED PART and PURCHASED PART

PART

Description

Part_No Qty_on_hand

Location

MANUFACTUREDPART

Routing_number

PURCHASEDPART

SUPPLIER

Supplier_ID

Supplies

Unit_Price

M

N

Database ManagementCOP4540, SCS, FIU

Constraints in Supertype/Subtype Relationships (1)

• Completeness Constraints: Whether an instance of a supertype must also be a member of at least one subtype.– Total Specialization Rule: the double line

convention– Partial Specialization Rule: default (single line)

Database ManagementCOP4540, SCS, FIU

Example of Completeness constraints

PATIENT

IDAdmit_date

Is_cared_forRESPONSIBLE

PHYSICIAN

Physician_ID

OUTPATIENTRESIDENTPATIENT

Checkback_dateDate_discharged

BED

Bed_ID

Is_assigned1 1

1N

Database ManagementCOP4540, SCS, FIU

• Disjointness Constraints: Whether an instance of a supertype may simultaneously be a member of two (or more) subtypes– Disjoint Rule: the symbol “d”– Overlap Rule: the symbol “o”

Constraints in Supertype/Subtype Relationships (2)

Database ManagementCOP4540, SCS, FIU

Example of disjointness constraints(a) Disjoint rule

PATIENT

IDAdmit_date

Is_cared_forRESPONSIBLE

PHYSICIAN

Physician_ID

OUTPATIENTRESIDENTPATIENT

Checkback_dateDate_discharged

BED

Bed_ID

Is_assigned1 1

1N

d

Database ManagementCOP4540, SCS, FIU

(b) Overlap rule

PART

Description

Part_No Qty_on_hand

Location

MANUFACTUREDPART

Routing_number

PURCHASEDPART

SUPPLIER

Supplier_ID

Supplies

Unit_Price

M

N

o

Database ManagementCOP4540, SCS, FIU

Constraints in Supertype/Subtype Relationships

• Subtype Discriminators: An attribute of the supertype whose values determine the target subtypes(s).– Disjoint (one subtype for each instance)– Overlapping (multiple subtypes possible)

• Such subtype is said to be predicate-defined.

Database ManagementCOP4540, SCS, FIU

Example of Subtype Discriminator (1)

EMPLOYEE

Name Address

Date_hiredSSN

HOURLYEMPLOYEE

SALAREDEMPLOYEE CONSULTANT

Hourly_rate Annual_salary Stock_option Contract_No. Billing_rate

Type

Type = ‘H” Type = ‘C’

Type =

‘S’

d

Database ManagementCOP4540, SCS, FIU

Example of Subtype Discriminator (2)

PART

Description

Part_No Qty_on_hand

Location

MANUFACTUREDPART

Routing_number

PURCHASEDPART

SUPPLIER

Supplier_ID

Supplies

Unit_Price

M

N

o

Part_type

M?

P?

M?=‘Y’ P?=‘Y’

Database ManagementCOP4540, SCS, FIU

Modeling of UNION Types Using Category

• A category has two or more supertypes.

• Attribute inheritance works more selectively in the case of categories.

• If a category is total (not partial), it may be represented alternatively as a specialization.

Database ManagementCOP4540, SCS, FIU

Example of Category (1)

COMPANY PERSON

ACCOUNTHOLDER BANKHas_Acct

M N

U

Database ManagementCOP4540, SCS, FIU

Example of Category (2)

BUILDING LOT

U

PROPERTY

PROPERTY

d

BUILDING LOT

Database ManagementCOP4540, SCS, FIU

An EER Conceptual schema for a university database

Figure 4.10