Subclass, Superclass and Inheritance in EER



In traditional ER diagrams, we use the entities and their relationships with rectangles and diamonds, respectively. The Enhanced Entity-Relationship (EER) model extends the traditional ER model to support more complex database designs. In EER, we have new concepts such as subclasses, superclasses, and inheritance that are particularly useful in representing real-world entities and their relationships in a structured and hierarchical way. These useful features make EER models suitable for applications like as engineering design, telecommunications, and complex organizational systems.

In this chapter, we will understand in detail the concepts of subclasses, superclasses, inheritance, and their associated processes of specialization and generalization with examples for a better understanding.

Subclasses and Superclasses

A superclass shows a broad category of entities, however its subclasses define more specific groupings within that category. The superclass-subclass relationship helps us model hierarchical data.

For example, consider the EMPLOYEE entity type in a company’s database. It is a broad category that might include subclasses such as:

  • SECRETARY − Employees who handle administrative tasks.
  • TECHNICIAN − Employees who provide technical support or services.
  • ENGINEER − Employees who design and develop systems or products.
Subclasses and Superclasses EER

The EMPLOYEE entity type is like the superclass, it has the shared characteristics of all employees. The specific roles like ENGINEER or SECRETARY are the subclasses.

The Class / Subclass Relationship

The connection between a superclass and its subclasses is known as the class-subclass relationship. This relationship shows that entities in a subclass are also members of the superclass.

For example, a TECHNICIAN entity is an EMPLOYEE with additional characteristics specific to the TECHNICIAN role. Similarly, a SECRETARY is an EMPLOYEE but with unique attributes, such as Typing_speed. This relationship is often described using an "is-a" relationship:

  • A TECHNICIAN is an
  • A SECRETARY is an
The Class / Subclass Relationship

EER diagrams illustrate these relationships clearly –

  • Like ER diagrams, rectangles represent entities (both superclasses and subclasses).
  • Circles denote specialization or generalization processes.
  • Subset symbols point from subclasses back to their superclass.

For example, the EMPLOYEE superclass connects to its subclasses through a circle. Specific attributes, like Typing_speed for SECRETARY, are attached to the respective subclass rectangle.

Inheritance in Superclass-Subclass Relationship

Inheritance is one of the key features of the superclass-subclass relationship. Inheritance ensures that entities in a subclass retain the attributes and relationships of their superclass. It is used to enables reuse and prevents redundancy.

Attribute Inheritance

Entities in a subclass inherit −

  • Superclass Attributes − For instance, all EMPLOYEES might have attributes such as Name, SSN, and Address. These are inherited by subclasses like ENGINEER and TECHNICIAN.
  • Subclass-Specific Attributes − Each subclass has its unique attributes. For example –
    • SECRETARY might have Typing_speed.
    • TECHNICIAN might have Tgrade.

This hierarchical organization helps ensure that common characteristics remain at the superclass level while allowing subclasses to specialize further.

Relationship Inheritance

Subclasses also inherit the relationships of their superclasses. For example, If EMPLOYEE participates in a MANAGES relationship with a PROJECT, all subclasses of EMPLOYEE inherit this relationship.

This flexibility is useful for subclasses to focus on unique relationships while sharing inherited ones.

Specialization: Defining Subclasses

Specialization is the process of dividing a superclass into meaningful subclasses based on specific characteristics. This process is used in designing database schema that reflects real-world distinctions.

Types of Specialization

Predicate-Defined Specialization − Subclass membership can be found in conditions on a superclass attribute. Like Subclasses of EMPLOYEE might be defined based on the attribute named "Job_type":

  • SECRETARY if Job_type = "Secretary".
  • TECHNICIAN if Job_type = "Technician".

User-Defined Specialization − Membership in subclasses is manually assigned by users. This is not determined by predefined conditions.

Overlapping vs. Disjoint Specialization

Specializations can be:

  • Disjoint − Entities belong to at most one subclass. For example, An EMPLOYEE can be either HOURLY_EMPLOYEE or SALARIED_EMPLOYEE, but not both.
  • Overlapping − Entities may belong to multiple subclasses. For example: A SALARIED_EMPLOYEE might also be a MANAGER.

Total vs. Partial Specialization

  • Total Specialization − Every entity in the superclass must belong to at least one subclass. Like every EMPLOYEE must be either HOURLY_EMPLOYEE or SALARIED_EMPLOYEE.
  • Partial Specialization − Some entities in the superclass do not belong to any subclass. Like some EMPLOYEES might not fit into SECRETARY, ENGINEER, or TECHNICIAN subclasses.

These entities have been represented in the following figure –

Total vs. Partial Specialization

Generalization: Abstracting Superclasses

Generalization is the reverse process of specialization. Generalization identifies common attributes or relationships among multiple entity types and abstracts them into a single superclass.

For example, consider the following entity types:

  • CAR: Attributes include License_plate_no and Vehicle_id.
  • TRUCK: Attributes include Tonnage and No_of_axles.

These entities share common attributes like License_plate_no and Vehicle_id. Through generalization, these common attributes can be combined into a VEHICLE superclass, with CAR and TRUCK as its subclasses.

Combining Specialization and Generalization

In real-world examples, database design is often used in a mix of specialization and generalization –

  • Specialization refines entity types by breaking them into specific subgroups.
  • Generalization abstracts multiple entity types into broader categories.

For instance, in a university database:

  • Specialization might divide PERSON into EMPLOYEE, STUDENT, and ALUMNUS.
  • Generalization might combine FACULTY and STAFF into an EMPLOYEE superclass.

Example: University Database

Now let us consider a university database to showcase the practical application of these concepts –

  • Superclass − PERSON, with attributes like Name, SSN, Birth_date, and Address.
  • Subclasses
    • EMPLOYEE − Specialized into FACULTY, STAFF, and STUDENT_ASSISTANT.
    • STUDENT − Specialized into GRADUATE_STUDENT and UNDERGRADUATE_STUDENT.

Shared Subclasses and Lattices

Sometimes a subclass belongs to multiple superclasses, forming a shared subclass. For example, STUDENT_ASSISTANT is a subclass of both STUDENT and EMPLOYEE. This creates a lattice structure, where entities inherit attributes from multiple paths.

For example:

  • A GRADUATE_STUDENT inherits attributes from STUDENT and PERSON.
  • A STUDENT_ASSISTANT inherits from both STUDENT and EMPLOYEE.
Shared Subclasses and Lattices

Advantages of Subclasses, Superclasses, and Inheritance

Following are the advantages of using subclasses, superclasses, and inheritance in Enhanced ER diagrams –

  • Efficient Data Representation − Common attributes are stored in the superclass, reducing redundancy.
  • Flexibility − Subclasses can add specific details while retaining shared attributes and relationships.
  • Real-World Alignment − The hierarchical structure mirrors real-world scenarios, simplifying database design and usage.

Conclusion

In this chapter, we covered the role of subclasses, superclasses, and inheritance in Extended ER diagrams. These new features help database designers to create flexible, scalable, and accurate schemas. Through specialization and generalization, entities can be refined or abstracted as needed, to align the database structure with real-world complexities. With these tools, the EER model provides a more robust framework for representing complex relationships.

Advertisements