You are on page 1of 15

Database Systems

Generalization/Specialization

Database Systems Slide 1


Generalization / Specialization

• Generalization and Specialization and are fundamental concepts in


database modeling that are useful for establishing superclass-
subclass relationships.

• Generalization is a bottom-up approach in which multiple lower-level


entities are combined to form a single higher-level entity.
Generalization is usually used to find common attributes among
entities to form a generalized entity. It can also be thought of as the
opposite of specialization.

• The following enhanced entity relationship diagram expresses


entities in a hierarchical database to demonstrate generalization:

Database Systems Slide 2


Generalization

Database Systems Slide 3


Specialization

• Specialization is a top-down approach in which a higher-level entity is


divided into multiple specialized lower-level entities. In addition to
sharing the attributes of the higher-level entity, these lower-level
entities have specific attributes of their own. Specialization is usually
used to find subsets of an entity that has a few different or additional
attributes.

• The following enhanced entity relationship diagram expresses the


entities in a hierarchical database to demonstrate specialization

Database Systems Slide 4


Specialization

Database Systems Slide 5


Specialization Process

• Specialization is a process in which an entity is divided into sub-


entities. You can think of it as a reverse process of generalization, in
generalization two entities combine together to form a new higher level
entity. Specialization is a top-down process.

• The idea behind Specialization is to find the subsets of entities that


have few distinguish attributes. For example – Consider an entity
employee which can be further classified as sub-entities Technician,
Engineer & Accountant because these sub entities have some
distinguish attributes.

Database Systems Slide 6


Generalization Process

• Generalization is a process in which the common attributes of more


than one entities form a new entity. This newly formed entity is called
generalized entity.

• Generalization uses bottom-up approach where two or more lower


level entities combine together to form a higher level new entity.

• The new generalized entity can further combine together with lower
level entity to create a further higher level generalized entity.

Database Systems Slide 7


Super Class / SubClass
• A superclass is the class from which many subclasses
can be created. The subclasses inherit the characteristics
of a superclass. The superclass is also known as the
parent class or base class.

• A subclass is a class derived from the superclass. It


inherits the properties of the superclass and also contains
attributes of its own.

• Vehicle is the Superclass and its subclasses are Car,


Truck and Motorcycle.

Database Systems Slide 8


Inheritance
• Inheritance is basically the process of basing a class on
another class i.e. to build a class on a existing class. The
new class contains all the features and functionalities of
the old class in addition to its own.

• The class which is newly created is known as the


subclass or child class and the original class is the parent
class or the superclass.

Database Systems Slide 9


Single Table Inheritance

• Single table inheritance is a way to emulate object-


oriented inheritance in a relational database. When
mapping from a database table to an object in an object-
oriented language, a field in the database identifies what
class in the hierarchy the object belongs to. All fields of
all the classes are stored in the same table, hence the
name "Single Table Inheritance".

Database Systems Slide 10


Super Classes / SubClasses Relationships

Database Systems Slide 11


Attribute Inheritance
• The attributes of a higher level entity set are inherited
through a lower level entity set made by specialization-
generalization hierarchy. Namely, all the attributes of the
higher level entity set are as well the attributes of the lower
level entity set.

Database Systems Slide 12


Aggregation
• Aggregation represents relationship between a whole
object and its component. Using aggregation we can
express relationship among relationships. Aggregation
shows ‘has-a’ or ‘is-part-of’ relationship between entities
where one represents the ‘whole’ and other ‘part’.

• Consider a ternary relationship Works_On between


Employee, Branch and Manager. Now the best way to
model this situation is to use aggregation, So, the
relationship-set, Works_On is a higher level entity-set.
Such an entity-set is treated in the same manner as any
other entity-set. We can create a binary relationship,
Manager, between Works_On and Manager to represent
who manages what tasks (shown in fig.).
Database Systems Slide 13
Aggregation

Database Systems Slide 14


Aggregation

Database Systems Slide 15

You might also like