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


5

Diagrammatically representation of specialization in an EER diagram


Esuper

Specific attributes

Specific attributes

E1

E2

Example
EMPLOYEE d

MANAGER

HOURLY_EMP

SECRETARY

TECHNICIAN

ENGINEER

SALARIED_EMP

MANAGES

BELONGS_TO

PROJECT

TRADE_UNION

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
8

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

Generalization (cont.)
NoOfPassengers MaxSpeed VehicleID LicensePlateNo NoOfAxies Tonnage VehicleID LicensePlateNo

CAR

Price

TRUCK

Price

VehicleID

Price

LicensePlateNo

VEHICLE

NoOfPassengers MaxSpeed

CAR

NoOfAxies

TRUCK

Tonnage
10

Generalization (cont.)
We can view {CAR, TRUCK} as a specialization of VEHICLE Alternatively, we can view VEHICLE as a generalization of CAR and TRUCK

11

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.

12

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
13

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.

14

Example
Name SSN BirthDate Address EMPLOYEE

TypeSpeed

EngType

PayScale

TGrade

Salary

SECRETARY

TECHNICIAN

ENGINEER

SALARIED_EMP

HOURLY_EMP

Disjoint subclasses

Disjoint subclasses
15

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.

16

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.

17

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.

18

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

19

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.
20

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 bottomup conceptual synthesis. we typically start with an entity type of subclasses and then define super classes of the entity type by successive generalization.

21

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.

23

Modeling of UNION Types Using Categories (cont.)


SSN DriverLicenseNo Name BName Address BANK PERSON BAddress CName CAddress

COMPANY

U
LienOrRegular PurchaseDate OWNS N CModel CMake CStyle VehicelId CYear TMake TYear REGISTERED_VEHICLE TModel Tonnage VehicleId
24

OWNER M

U
TRUCK

CAR

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.

28

name

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 for purposes of participation in (other) relationships.

ssn Employees

lot

Monitors

until

started_on pid Projects pbudget

since did

dname budget Departments

Sponsors

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

Vous aimerez peut-être aussi