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

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

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

Page 1: 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

Page 2: Database Management COP4540, 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

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

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

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

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

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

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.

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

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

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

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.

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

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

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

Database ManagementCOP4540, SCS, FIU

VEHICLEPrice

VIN Name

Make Model

EngineDisplacement

Year

CARNo_of_Passengers

TRUCK Capacity

Cab_type

(b) Generalization to VEHICLE supertype

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

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

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

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

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

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)

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

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

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

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)

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

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

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

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

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

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.

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

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

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

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’

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

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.

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

Database ManagementCOP4540, SCS, FIU

Example of Category (1)

COMPANY PERSON

ACCOUNTHOLDER BANKHas_Acct

M N

U

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

Database ManagementCOP4540, SCS, FIU

Example of Category (2)

BUILDING LOT

U

PROPERTY

PROPERTY

d

BUILDING LOT

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

Database ManagementCOP4540, SCS, FIU

An EER Conceptual schema for a university database

Figure 4.10