Specialization and Generalization
1. Specialization
Specialization is the process of defining a set of subclasses of an entity type; this entity
type is called the superclass of the
specialization. The set of subclasses that forms a specialization is defined on
the basis of some distinguishing characteristic of the entities in the
superclass. For example, the set of subclasses {SECRETARY, ENGINEER,
TECHNICIAN} is a specialization of the
superclass
EMPLOYEE that distinguishes among
employee entities based on the job type
of each employee entity. We may have several specializations of the same entity
type based on different distinguishing characteristics. For example, another
specialization of the EMPLOYEE entity type may yield the set of
subclasses {SALARIED_EMPLOYEE, HOURLY_EMPLOYEE}; this specialization distinguishes among employees based on the method of pay.
Figure 8.1 shows how we represent a specialization diagrammatically in
an EER diagram. The subclasses that define a specialization are attached by
lines to a circle that represents the specialization, which is connected in
turn to the superclass. The subset symbol
on each line connecting a subclass to the circle indicates the direction of the superclass/subclass
relationship. Attributes that apply only to entities of a particular subclass—such as
TypingSpeed of SECRETARY—are attached to the rec-tangle representing that subclass. These are
called specific attributes (or local attributes) of the subclass.
Similarly, a subclass can participate in
specific relation-ship types, such as the HOURLY_EMPLOYEE subclass participating in the BELONGS_TO relationship in Figure 8.1. We will explain the d symbol in the circles in Figure 8.1 and additional EER
diagram notation shortly.
Figure 8.2 shows a few entity instances that belong to subclasses of the
{SECRETARY, ENGINEER, TECHNICIAN} specialization. Again, notice that an entity that belongs to a
subclass represents the same real-world
entity as the entity connected to it in the EMPLOYEE
superclass, even though the same entity is shown twice; for example, e1 is shown in both EMPLOYEE and SECRETARY in Figure 8.2. As the figure suggests, a superclass/subclass
relationship such as EMPLOYEE/ SECRETARY somewhat
resembles a 1:1 relationship at the
instance level
(see Figure 7.12).
The main difference is that in a 1:1 relationship two distinct entities are related, whereas in a superclass/subclass
relationship the entity in the subclass is the same real-world entity as the
entity in the superclass but is playing a specialized
role—for example, an EMPLOYEE specialized
in the role of SECRETARY, or an EMPLOYEE specialized in the role of TECHNICIAN.
There are two main reasons for including class/subclass relationships
and specializations in a data model. The first is that certain attributes may
apply to some but not all entities of the superclass. A subclass is defined in
order to group the entities to which these attributes apply. The members of the
subclass may still share the majority of their attributes with the other
members of the superclass. For example, in Figure 8.1 the SECRETARY subclass has the specific attribute Typing_speed, whereas
the ENGINEER subclass has the specific attribute Eng_type, but SECRETARY and
ENGINEER share their other inherited
attributes from the EMPLOYEE entity type.
The second reason for using subclasses is that some relationship types
may be participated in only by entities that are members of the subclass. For
example, if only HOURLY_EMPLOYEES
can belong to a trade union, we can represent that
fact by
creating the subclass HOURLY_EMPLOYEE of EMPLOYEE and relating the subclass to an entity type TRADE_UNION via the BELONGS_TO relationship type, as illus-trated in Figure 8.1.
In summary, the specialization process allows us to do the following:
Define a set of subclasses 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
2. Generalization
We can think of a reverse process
of abstraction in which we suppress the differences among several entity types,
identify their common features, and generalize
them into a single superclass of
which the original entity types are special subclasses. For example, consider the entity types CAR and TRUCK shown in Figure 8.3(a). Because they have several common attributes,
they can be generalized into the entity type VEHICLE, as
shown in Figure 8.3(b). Both CAR and TRUCK are now
subclasses of the
generalized
superclass VEHICLE. We use the term generalization to
refer to the process of defining a
generalized entity type from the given entity types.
Notice that the generalization process can be viewed as being
functionally the inverse of the specialization process. Hence, in Figure 8.3 we
can view {CAR, TRUCK} as a specialization of VEHICLE, rather
than viewing VEHICLE as a generalization of CAR and TRUCK. Similarly, in Figure 8.1 we can view EMPLOYEE as a
generalization of SECRETARY,
TECHNICIAN, and ENGINEER. A diagrammatic notation to distinguish between
generalization and specialization is used in some design methodologies. An
arrow pointing to the generalized superclass represents a generalization,
whereas arrows pointing to the specialized subclasses represent a
specialization. We will not use this
notation because the decision as to which process is followed in a particular
situation is often subjective. Appendix A gives some of the suggested
alternative dia-grammatic notations for schema diagrams and class diagrams.
So far we have introduced the concepts of subclasses and
superclass/subclass relationships, as well as the specialization and
generalization processes. In general, a
superclass or subclass represents a collection of entities of the same
type and hence also describes an entity
type; that is why superclasses and subclasses are all shown in rectangles
in EER diagrams, like entity types. Next, we discuss the properties of
specializations and generalizations in more detail.
Related Topics
Privacy Policy, Terms and Conditions, DMCA Policy and Compliant
Copyright © 2018-2023 BrainKart.com; All Rights Reserved. Developed by Therithal info, Chennai.