Vous êtes sur la page 1sur 30

Database Systems &Applications

Lecture 6

EER concepts(cntd.)

EER Modeling

Sub classes, Super classes and Inheritance

Specialization and Generalization

Constraints and Characteristics of Specialization and Generalization

Modeling of UNION Types Using Categories

Specialization

The process of defining a set of subclass of an entity type (the super class of the specialization).

The set of subclasses that form a specialization is defined on the basis of some distinguishing characteristics of the entities in the super class.

{SECRETARY, ENGINEER, TECHNICIAN} is a specialization of EMPLOYEE based on the job type of each entity.

Specialization (cont.)

The same entity type may have several specializations based on different distinguishing characteristics.

The EMPLOYEE entity type may have two specializations:

Based on the methods of pay:

{SALARIED_EMPLOYEE, HOURLY_EMPLOYEE} Based on the type of job:

{SECRETARY, ENGINEER, TECHNICIAN}

A subclass can participate in specific relationship type

Diagrammatically representation of specialization in an EER diagram

Diagrammatically representation of specialization in an EER diagram … E super Specific Specific attributes attributes …
Diagrammatically representation of specialization in an EER diagram … E super Specific Specific attributes attributes …

E super
E super
Specific Specific attributes attributes … … E 2 E 1
Specific
Specific
attributes
attributes
E 2
E 1

Example

EMPLOYEE

d
d

TECHNICIAN

d MANAGER
d
MANAGER

SALARIED_EMP

HOURLY_EMP

MANAGES
MANAGES
 

PROJECT

BELONGS_TO
BELONGS_TO
 

TRADE_UNION

SECRETARY

ENGINEER

Specialization

The specialization process allows us to do the following:

Define a set of subclass of an entity type

Establish additional specific attributes with each subclass

Establish additional specific relationship types between each subclass and other entity types or other subclasses

Generalization

Generalization is the reverse of specialization process. It defines a generalized entity type from the given entity types.

Generalization (cont.)

NoOfPassengers LicensePlateNo MaxSpeed CAR Price VehicleID
NoOfPassengers
LicensePlateNo
MaxSpeed
CAR
Price
VehicleID
NoOfAxies LicensePlateNo Tonnage TRUCK Price VehicleID
NoOfAxies
LicensePlateNo
Tonnage
TRUCK
Price
VehicleID
Generalization (cont.) NoOfPassengers LicensePlateNo MaxSpeed CAR Price VehicleID NoOfAxies LicensePlateNo Tonnage TRUCK Price VehicleID VehicleID Price
VehicleID
VehicleID
Price
Price
LicensePlateNo
LicensePlateNo

VEHICLE

NoOfPassengers d NoOfAxies MaxSpeed CAR Tonnage TRUCK
NoOfPassengers
d
NoOfAxies
MaxSpeed
CAR
Tonnage
TRUCK

Generalization (cont.)

We can view {CAR, TRUCK} as a specialization of VEHICLE

Alternatively, we can view VEHICLE as a generalization of CAR and TRUCK

Generalization (cont.)

Generalization suppresses the difference among several entity types, identifying their common features, and generalize them into a single super class of which the original types are special sub classes.

The decision as to which process, generalization or specialization, is more appropriate in a particular situation is often subjective.

Constraints on Specialization/Generalization

Disjoint vs. Overlap Constraints

A total specialization vs. a partial specialization

Specialization/Generalization hierarchies and lattices

Utilizing specialization and generalization in Conceptual Data Modeling

Disjointness Constraint

Disjoint(d) constraint specifies that the sub classes of the specialization must be disjointed (an entity can be a member of at most one of the subclasses of the specialization)

In EER diagram, d in the circle stands for disjoint.

Example

Name
Name
SSN
SSN
BirthDate
BirthDate
Address
Address

EMPLOYEE

d TypeSpeed TGrade EngType SECRETARY TECHNICIAN ENGINEER
d
TypeSpeed
TGrade
EngType
SECRETARY
TECHNICIAN
ENGINEER
Example Name SSN BirthDate Address EMPLOYEE d TypeSpeed TGrade EngType SECRETARY TECHNICIAN ENGINEER Disjoint subclasses d

Disjoint subclasses

Example Name SSN BirthDate Address EMPLOYEE d TypeSpeed TGrade EngType SECRETARY TECHNICIAN ENGINEER Disjoint subclasses d
d Salary PayScale HOURLY_EMP
d
Salary
PayScale
HOURLY_EMP
Example Name SSN BirthDate Address EMPLOYEE d TypeSpeed TGrade EngType SECRETARY TECHNICIAN ENGINEER Disjoint subclasses d

Disjoint subclasses

Example Name SSN BirthDate Address EMPLOYEE d TypeSpeed TGrade EngType SECRETARY TECHNICIAN ENGINEER Disjoint subclasses d

SALARIED_EMP

Overlap Constraint

Overlap(o) specifies that the subclasses are not constrained to be disjoint, i.e., the same (real-world) entity may be a member of more than one subclass of the specialization.

Overlap is the default constraint and displayed by placing an o in the circle.

Completeness constraint

Completeness constraint may be total or partial.

A total specialization constraint specifies that every entity in the super class must be a member of some subclass in the specialization.

Represented by a double line connecting the super class to the circle.

Completeness constraint (cont.)

A partial specialization allows an entity not to belong to any of the subclasses, using a single line in EER.

e.g., if some EMPLOYEE entities, for example, sales representatives, do not belong to any of the subclasses {SECRETARY, ENGINEER, TECHNICIAN}, then the specialization is partial.

Represented by a single line connecting the superclass to the circle.

Four Possible Constraints

The disjointness and completeness constraints are independent.

There are four possible constraints on specialization:

Disjoint, total Disjoint, partial Overlapping, total Overlapping, partial

Some insertion and deletion rules applied to specialization/generalization

Deleting an entity from a super class implies that it is automatically deleted from all the subclasses to which it belongs

Inserting an entity in a super class implies that the entity is mandatorily inserted in all applicable subclasses.

Inserting an entity in a super class of a total specialization implies that the entity is mandatorily inserted in at least one of the subclasses of the specialization.

The differences between the specialization and generalization

The specialization process corresponds to a top-down conceptual refinement process during conceptual schema design.

we typically start with an entity type and then define subclasses of the entity type by successive specialization;

The generalization process corresponds to a bottom- up conceptual synthesis.

we typically start with an entity type of subclasses and then define super classes of the entity type by successive generalization.

Specialization/Generalization hierarchies and lattices

Specialization/Generalization hierarchies and lattices

Modeling of UNION Types Using Categories

It is possible that single super class/subclass relationship has more than one super class representing different entity types. In this case, the subclass will represent a collection of objects that is (a subset of) the UNION of distinct entity types; we call such a subclass a union type or a category.

A category has two or more super classes that may represent distinct entity types, whereas non-category super class/subclass relationships always have a single super class.

Modeling of UNION Types Using Categories (cont.)

BName
BName
Name SSN Address DriverLicenseNo PERSON
Name
SSN
Address
DriverLicenseNo
PERSON
BAddress
BAddress
CName
CName
CAddress
CAddress

BANK

   

COMPANY

U
U
Modeling of UNION Types Using Categories (cont.) BName Name SSN Address DriverLicenseNo PERSON BAddress CName CAddress
LienOrRegular OWNER M PurchaseDate OWNS N CModel REGISTERED_VEHICLE TModel CMake TYear TMake CStyle CYear Tonnage U
LienOrRegular
OWNER
M
PurchaseDate
OWNS
N
CModel
REGISTERED_VEHICLE
TModel
CMake
TYear
TMake
CStyle
CYear
Tonnage
U
VehicelId
CAR
TRUCK
VehicleId

Modeling of UNION Types Using Categories (cont.)

Two categories in car registration database.

OWNER is a subclass of the union of PERSON, BANK, and COMPANY

REGISTRERED_VEHICLE is a subclass of the union of CAR and TRUCK

An entity that is a member of OWNER must exist in only one of the super class.

Attribute inheritance works more selectively in the case of categories.

e.g., each OWNER entity inherits the attributes of a COMPANY, a PERSON, or a BANK, depending on the super class to which the entity belongs.

25

A Category can be total or partial?

A category Or A Specialization

The superclass of a category may have different key attributes.

If a category is total (not partial), it may be represented alternatively as a specialization, and the choice of which representation to use is subjective.

A category Or A Specialization (cont.)

If the two classes represent the same type of entities and share numerous attributes, including the same key attributes, specialization/generalization is preferred; otherwise, categorization is more appropriate.

name ssn lot Employees
name
ssn
lot
Employees

Aggregation

Used when we have to model a relationship involving (entity sets and) a relationship set.

Aggregation allows us to treat a relationship set as an

entity set purposes of

for

Monitors until started_on since dname pid pbudget did budget Sponsors Projects Departments
Monitors
until
started_on
since
dname
pid
pbudget
did
budget
Sponsors
Projects
Departments

Aggregation vs. ternary relationship:

participation in (other) relationships.

Monitors is a distinct relationship, with a descriptive attribute. (i.e., until) Also, can say that each sponsorship is monitored by at most one employee.