cs 157a: intro to database sys summary of chapter section 4.1 of the textbook data modeling and...

18
CS 157A: Intro to Database Sys Summary of Chapter Section 4.1 of the textbook Data Modeling and Database Design Copyright 2007 Thomson Course Technology Presentation compiled by Michael Goebel 2007 September 06

Upload: shon-mckenzie

Post on 17-Dec-2015

220 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: CS 157A: Intro to Database Sys Summary of Chapter Section 4.1 of the textbook Data Modeling and Database Design Copyright 2007 Thomson Course Technology

CS 157A: Intro to Database Sys

Summary of Chapter Section 4.1 of the textbook Data Modeling and Database Design

Copyright 2007 Thomson Course Technology Presentation compiled by Michael Goebel 2007 September 06

Page 2: CS 157A: Intro to Database Sys Summary of Chapter Section 4.1 of the textbook Data Modeling and Database Design Copyright 2007 Thomson Course Technology

Enhanced Entity-Relationship (EER)Modeling: Superclass/Subclass

Relationship General Properties of Superclass/Subclass Specialization and Generalization Specialization Hierarchy Specialization Lattice Categorization Appropriate EER Construct Aggregation

Page 3: CS 157A: Intro to Database Sys Summary of Chapter Section 4.1 of the textbook Data Modeling and Database Design Copyright 2007 Thomson Course Technology

Inter-entity class relationship

You enter a store to buy a piece of furniture

Store and Furniture: different independent object types (aka entity types)

Store has Furniture (has-a relationship)

STORE

Sells

FURNITURE

Page 4: CS 157A: Intro to Database Sys Summary of Chapter Section 4.1 of the textbook Data Modeling and Database Design Copyright 2007 Thomson Course Technology

Intra-entity class relationship

Need to furnish your new apartment

You want a table, chairs, bed, etc.

These possess some common properties

Table/Chair/Bed is Furniture (is-a relationship)

FURNITURE

TABLE CHAIR BED

Page 5: CS 157A: Intro to Database Sys Summary of Chapter Section 4.1 of the textbook Data Modeling and Database Design Copyright 2007 Thomson Course Technology

Superclass and Subclass

No relationship type between Furniture and Chair/Bed/Table

Furniture can be many different things

Furniture is Superclass (SC)

Chair/Bed/Table is Subclass (sc)

CHAIR

BED

TABLE

FURNITURE

Page 6: CS 157A: Intro to Database Sys Summary of Chapter Section 4.1 of the textbook Data Modeling and Database Design Copyright 2007 Thomson Course Technology

Basic Properties of SC/sc

A Superclass/Subclass relationship One Superclass is related to one or more

Subclasses A Subclass entity only belongs to 1 Superclass A Superclass entity can belong to 1 or more (or

none) Subclasses Subclass inherits all attributes of Superclass Subclass can have its own attributes Cardinality ratio 1:1 is understood to exist

Page 7: CS 157A: Intro to Database Sys Summary of Chapter Section 4.1 of the textbook Data Modeling and Database Design Copyright 2007 Thomson Course Technology

New EER diagram notation for SC/sc

Total completeness Partial completeness Disjoint Subclass Overlapping Subclasses Union of Superclasses Aggregation of

Subclasses Identifies a Subclass

d

O

U

A

U

Page 8: CS 157A: Intro to Database Sys Summary of Chapter Section 4.1 of the textbook Data Modeling and Database Design Copyright 2007 Thomson Course Technology

Specialization / Generalization

Specialization is the process of discovering the distinguishing attributes of any subgroups and creating Subclasses

Specialization is a top-down approach to SC/sc Generalization is the process of gathering all

the common attributes shared by a group of entities and creating a Superclass

Generalization is a down-up approach to SC/sc

Page 9: CS 157A: Intro to Database Sys Summary of Chapter Section 4.1 of the textbook Data Modeling and Database Design Copyright 2007 Thomson Course Technology

More Specialization

Inclusion of a Superclass in the specialization is called a Completeness Constraint

Completeness Constraint can be either Total or Partial

Total Specialization: every entity of the Superclass participates in the specialization relationship (shown with a solid line)

Partial Specialization: 1 or more entities of the Superclass participates in the specialization relationship (shown with a dash line)

Page 10: CS 157A: Intro to Database Sys Summary of Chapter Section 4.1 of the textbook Data Modeling and Database Design Copyright 2007 Thomson Course Technology

Total/Partial Completeness

STUDENT_ATHLETE

FOOTBALL BASEBALL BASKETBALL

OTotal completeness

Partial completeness

UU

U

Page 11: CS 157A: Intro to Database Sys Summary of Chapter Section 4.1 of the textbook Data Modeling and Database Design Copyright 2007 Thomson Course Technology

More Specialization: Multiple

STUDENT_ATHLETE

FOOTBALL BASEBALL BASKETBALL

OTotal completeness

Partial completeness

UU

U

CAPTAIN

U

TEAM

Page 12: CS 157A: Intro to Database Sys Summary of Chapter Section 4.1 of the textbook Data Modeling and Database Design Copyright 2007 Thomson Course Technology

Predicate

How to directly determine the membership of a Subclass

Thru the use of a defining predicate

Student_Athlete Subclass membership are Sport_Teams

STUDENT_ATHLETE

FOOTBALL BASEBALL

O

UU

CAPTAIN

TEAM

SPORT_TEAMS

FOOTBALL

U

BASEBALL

Page 13: CS 157A: Intro to Database Sys Summary of Chapter Section 4.1 of the textbook Data Modeling and Database Design Copyright 2007 Thomson Course Technology

Specialization Hierarchy

Already know that a Superclass can have one or more Subclasses

Those Subclasses themselves can become Superclasses of other Subclasses

The structure of Superclass-Subclass-Superclass-Subclass-etc. is limited to an inverted tree

Limitation is that a Subclass can only be related to one Superclass specialization

Page 14: CS 157A: Intro to Database Sys Summary of Chapter Section 4.1 of the textbook Data Modeling and Database Design Copyright 2007 Thomson Course Technology

Specialization Lattice

Similar to the Specialization Hierarchy where a child (Subclass) is only allowed on parent (Superclass specialization)

The child (Subclass) is allowed to have 2 or more parents (Superclass) as long as each parent is from a different Specialization.

The Subclass then inherits all the attributes and relationship types from each parent, Multiple Type Inheritance

Page 15: CS 157A: Intro to Database Sys Summary of Chapter Section 4.1 of the textbook Data Modeling and Database Design Copyright 2007 Thomson Course Technology

Categorization

The idea that there is only one Superclass is the overriding characteristic of the Specialization/Generalization construct

When many Superclasses and a Subclass are tied together by a single relationship type this is known as Categorization

The Subclass is known as the Category An entity which belongs to the Category must

also exist in only one of the Superclasses

Page 16: CS 157A: Intro to Database Sys Summary of Chapter Section 4.1 of the textbook Data Modeling and Database Design Copyright 2007 Thomson Course Technology

Which EER Construct?

When to use Specialization/Generalization or Categorization

Not always easy to know: subjective and context specific

If Superclasses share many common attributes with same properties then Specialization/Generalization might work best

If Superclasses don't share much attributes but have a common category they could identify with, then Categorization might work best

Page 17: CS 157A: Intro to Database Sys Summary of Chapter Section 4.1 of the textbook Data Modeling and Database Design Copyright 2007 Thomson Course Technology

Aggregation

Aggregation (to combine) is similar to Categorization except that it must have Total Completeness

Aggregation plays the “is a part of” in a SC/sc relationship

PC

HARDWARE

OP_SYS

A

U

Page 18: CS 157A: Intro to Database Sys Summary of Chapter Section 4.1 of the textbook Data Modeling and Database Design Copyright 2007 Thomson Course Technology

THE END