Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

The ER Model has the power of expressing database entities in a conceptual hierarchical

manner. As the hierarchy goes up, it generalizes the view of entities, and as we go deep in the
hierarchy, it gives us the detail of every entity included.

Going up in this structure is called generalization, where entities are clubbed together to
represent a more generalized view. For example, a particular student named Mira can be
generalized along with all the students. The entity shall be a student, and further, the student is a
person. The reverse is called specialization where a person is a student, and that student is
Mira.

Generalization
As mentioned above, the process of generalizing entities, where the generalized entities contain
the properties of all the generalized entities, is called generalization. In generalization, a number
of entities are brought together into one generalized entity based on their similar characteristics.
For example, pigeon, house sparrow, crow and dove can all be generalized as Birds.

In Employee example, we have seen different types of employees like Engineer, Accountant,
Salesperson, Clerk etc. Similarly each employee belongs to different departments. We can
represent it in an ER diagram as below. When you see this diagram for the first time, you will not
understand it quickly. One will take time to understand it or he might misunderstand some
requirement.
However sub departments and different employee types have same features in their own domain.
So if we merge the child entities into their parent, it makes the diagram simpler, hence easy to
understand. This method of merging the branches into one is called generalization. We can see
the generalized structure of requirement to understand it quickly. So above ER diagram will be
changed to as below:

Generalization is the bottom up approach which helps to design the requirement at high level.

Specialization
Specialization is the opposite of generalization. In specialization, a group of entities is divided
into sub-groups based on their characteristics. Take a group Person for example. A person has
name, date of birth, gender, etc. These properties are common in all persons, human beings. But
in a company, persons can be identified as employee, employer, customer, or vendor, based on
what role they play in the company.

Similarly, in a school database, persons can be specialized as teacher, student, or a staff, based
on what role they play in school as entities.

In the above Employee example, Department entity is further divided into sub departments to
understand how they are scattered. This method of representation helps the developer to code
correctly and quickly. It is a top down approach of breaking higher level entity to low level
entity. Once the entities are understood at higher level, it makes easy to understand the
requirement at low level.

Inheritance
We use all the above features of ER-Model in order to create classes of objects in object-
oriented programming. The details of entities are generally hidden from the user; this process
known as abstraction.

Inheritance is an important feature of Generalization and Specialization. It allows lower-level


entities to inherit the attributes of higher-level entities.

For example, the attributes of a Person class such as name, age, and gender can be inherited by
lower-level entities such as Student or Teacher.

Aggregation

Look at below ER diagram of STUDENT, COURSE and SUBJECTS. What does it infer?
Student attends the Course, and he has some subjects to study. At the same time, Course offers
some subjects. Here a relation is defined on a relation. But ER diagram does not entertain such a
relation. It supports mapping between entities, not between relations. So what can we do in this
case?
If we look at STUDENT and COURSE from SUBJECTs point of view, it does not differentiate
both of them. It offers its subject to both of them. So what can we do here is, merge STUDENT
and COURSE as one entity. This process of merging is called aggregation. It is completely
different from generalization. In generalization, we merge entities of same domain into one
entity. In this case we merge related entities into one entity.

Here we have merged STUDENT and COURSE into one entity STUDENT_COURSE. This
new entity forms the mapping with SUBJECTS. The new entity STUDENT_COURSE, in turn
has two entities STUDENT and COURSE with Attends relationship.

You might also like