Generalization, specialization, and Aggregation in DBMS

Ankit Kumar
Last Updated: May 13, 2022

Prerequisite - We will be covering Generalization, specialization, and Aggregation. So you should have prior knowledge of entity, attributes, relationship, and the Entity-Relationship diagram.

Introduction

To store and process data, we create databases, but before that, we draw an Entity-Relationship diagram to get a brief idea about our requirements. These E-R diagrams give us a logical interpretation of the system. 

With every minute passing on, we are creating a tremendous amount of data and thus making it very complex to organize data correctly. To solve the complexity of an E-R diagram, we use its modified version known as Enhanced Entity-Relationship diagram, abbreviated as EER diagram.

If we try to draw a traditional E-R diagram for a massive database, it will be an apparent mess and somewhat look like this.            

Source- Dreamstime

To draw an EER diagram, we adopt the technique of Generalization, specialization, and Aggregation in DBMS and thus make our diagram organized.

If we draw an excellent EER diagram following all the necessary techniques, then our diagram would somewhat look clear, like this.

 

 Source- GettyImages

I hope you prefer to draw a more detailed and organized E-R diagram, as shown in the second figure.

As we have seen the importance of Generalization, specialization, and Aggregation in DBMS, we will now try to understand these in detail. Let us look at generalization first.

Generalization

In generalization, we group two or more low-level entities to form high-level entities. We know several entities may have many common attributes. We take their union and thus create a higher entity with all the specific qualities linked. All the different attributes will get connected to the particular entity.

It's a bottom-to-top approach, and it helps to reduce the size and complexity of the schema.

Let us look at an example for this, making it clearer to understand.

Example

Let us take two low-level entities as Biology and History, and these two will have many common attributes and some specific attributes. And We will generalize and link the common attributes to the newly formed high-level entity named Subject.

Following is the diagram for this.

The above diagram generalizes the subjects History and Biology, forming a new entity called Subject and linking the common attributes with it.

Let us now understand the concept of specialization.

Specialization

It can be understood as the reverse of generalization. It is a top to down approach and increases the schema's size. In specialization, any superclass is further divided into subclasses based on its characteristics. The concept of inheritance is somewhat similar to a specialization.

Let us understand this more clearly with an example.

Example

For an entity Businessman in an income management system, we can further specialize it into other entities like Contractor and Shopkeeper. The common attributes will get linked to the entity Businessman, whereas the specific qualities will be connected to the Contractor and Shopkeeper.

Let us now look at the diagram for a more precise understanding of specialization.

This diagram explains the concept of specialization.

Now we will look at the last yet essential topic aggregation in DBMS

Aggregation

Aggregation denotes the connection between a total item and its constituents. We may represent relationships among relationships via Aggregation. Aggregation depicts a 'has-a' or 'is-part-of' relationship between entities, one representing the 'whole' and the other representing the 'part.'

Example 

Consider a ternary connection between an employee, a branch, and a manager called Works On. Aggregation is now the best technique to model this scenario. As a result, the Work On relationship-set is a higher-level entity-set. The same rules apply to this entity-set as any other entity set. To express who supervises which tasks, we may establish a binary connection between Works On and Manager called Manager.

This diagram explains the concept of Aggregation.

Frequently asked question

Q1 What are the differences between generalization and specialization?

Ans- 

                  Generalization                    Specialization
It is a bottom to top approachIt is a top to down approach
It reduces the size of the schema It expands the size of the schema
It uses inheritanceInheritance is not used

Q2 Is it necessary to use generalization, specialization, and aggregation concepts every time while drawing an E-R diagram?

Ans- No, It all depends on the size and complexity of the schema given to us.

Q3 To draw the best E-R diagram, which concept should we prefer?

Ans- There is no general case for choosing the best concept, It totally depends on the requirements in the database.

We come to the end of this blog with answers to these questions. Let us summarize what we learned.

Key takeaways

We read about Generalization, Specialization, and Aggregation concepts in the article. We dived deep into the concepts through one example of each. We saw how these techniques are essential in today's scenario of creating humongous databases. A traditional E-R Diagram can make things complicated for such large databases. For our relief, we use the Enhanced-Entity-Relationship Model. Using the techniques can make our diagram more organized.

NInjas! You have taken the most crucial step in learning about the ER Diagrams.

Do not stop here and learn all of the most required topics that will help you ace the placement interviews by joining our courses and checking Codestudio. You should check out the following list of top 100 questions to improve your knowledge of  SQL.

Was this article helpful ?
1 upvote

Comments

No comments yet

Be the first to share what you think