0% found this document useful (0 votes)
1K views29 pages

Superclass Subclass and Inheritance

1. Entity types can have subclasses that represent meaningful subgroups of entities, with the superclass representing a broader group. 2. Relationships between superclasses and subclasses are called "is-a" relationships, where subclasses inherit attributes and relationships from the superclass. 3. Specialization is the process of refining entity types into subclasses, while generalization identifies commonalities among types to define a superclass. In modeling, these processes are typically mixed.

Uploaded by

sehrish habib
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1K views29 pages

Superclass Subclass and Inheritance

1. Entity types can have subclasses that represent meaningful subgroups of entities, with the superclass representing a broader group. 2. Relationships between superclasses and subclasses are called "is-a" relationships, where subclasses inherit attributes and relationships from the superclass. 3. Specialization is the process of refining entity types into subclasses, while generalization identifies commonalities among types to define a superclass. In modeling, these processes are typically mixed.

Uploaded by

sehrish habib
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 29

EER Diagram

Prepared BY :
Mukhtar Qureshi
Subclasses, Superclasses, Inheritance

 • Entity types represent both kinds of entities and sets of entities of


that kind that exist in the database (e.g. entity type EMPLOYEE)
 • Often an entity type has different subgroups of its entities that
need to be represented explicitly in the database because of their
significance (e.g. SECRETARY, ENGINNER, MANAGER, TECHNICIAN
…)
 • The set of entities in each of these subgroups is a subset of the
EMPLOYEE entity set (every entity that is a member of one of these
subgroups is also an EMPLOYEE entity)
 • Each of these subgroups is called a subclass of the EMPLOYEE
entity type
 • The EMPLOYEE entity type is called the superclass of each of these
subclasses
 • The relationship between a superclass and any one of its
subclasses is called a superclass/subclass or class/subclass or IS-A
(IS-AN) relationship (e.g. EMPLOYEE/SECRETARY
EMPLOYEE/MANAGER)
Why we need EER modeling?
4  ER modeling concepts discussed Chapter 3 are sufficient for
representing many database schemas for "traditional" database
applications,
 Design more accurate database schemas that reflect the data
properties and constraints more precisely.
 Databases for engineering design
 Manufacturing
 Telecommunications
 Complex software systems
 Geographic Information Systems (GIs)
 More complex requirements
 Led to the development of additional semantic data modeling
concepts
Sir Syed Sarmad
Database Management Systems
Ali Shah
5 Enhanced-ER (EER) Model Concepts
Includes all modeling concepts of basic ER
Additional concepts: subclasses/superclasses,
specialization/generalization, categories,
attribute inheritance
The resulting model is called the Enhanced-ER or
Extended ER (E2R or EER) model
It is used to model applications more completely
and accurately with additional semantics
It includes some object-oriented concepts, such
as inheritance
Sir Syed Sarmad
Database Management Systems
Ali Shah
6 Subclasses and Superclasses (1)
 An entity type may have additional meaningful subgroupings
of its entities
 Example: EMPLOYEE may be further grouped into SECRETARY,
ENGINEER, MANAGER, TECHNICIAN, SALARIED_EMPLOYEE,
HOURLY_EMPLOYEE,…
 Each of these groupings is a subset of EMPLOYEE entities
 Each is called a subclass of EMPLOYEE
 EMPLOYEE is the superclass for each of these subclasses
 These are called superclass/subclass relationships.
 Example: EMPLOYEE/SECRETARY, EMPLOYEE/TECHNICIAN

Sir Syed Sarmad


Database Management Systems
Ali Shah
Subclasses and Superclasses (2)
7
 These are also called IS-A relationships (SECRETARY IS-A
EMPLOYEE, TECHNICIAN IS-A EMPLOYEE, …).
 Note: An entity that is member of a subclass represents the
same real-world entity as some member of the superclass
The Subclass member is the same entity in a distinct
specific role
An entity cannot exist in the database merely by being a
member of a subclass; it must also be a member of the
superclass
A member of the superclass can be optionally included
as a member of any number of its subclasses
 Example: A salaried employee who is also an engineer
belongs to the two subclasses ENGINEER and
SALARIED_EMPLOYEE
It is not necessary that every entity in a superclass be a
member of some subclass
Database Management Systems
Sir Syed Sarmad
Ali Shah
8 Example

Sir Syed Sarmad


Database Management Systems
Ali Shah
9

Attribute Inheritance in Superclass /


Subclass Relationships

An entity that is member of a


subclass inherits all attributes of the
superclass
It also inherits all relationships of the
superclass
Sir Syed Sarmad
Database Management Systems
Ali Shah
Subclasses and Superclasses
 An entity type may have subclasses of its entities
 Example: EMPLOYEE may be grouped into:
SECRETARY, ENGINEER, TECHNICIAN, …
Based on the EMPLOYEE’s Job
MANAGER
EMPLOYEEs who are managers
SALARIED_EMPLOYEE, HOURLY_EMPLOYEE
Based on the EMPLOYEE’s method of pay
 EMPLOYEE is the superclass for each of these
subclasses
Slide 10
Subclasses and Superclasses (2)

 Also called IS-A relationships


SECRETARY IS-A EMPLOYEE, TECHNICIAN IS-A
EMPLOYEE, ….

 An entity cannot exist in the database merely by


being a member of a subclass; it must also be a
member of the superclass

 A member of the superclass can be optionally


included as a member of any number of its
subclasses
Slide 11
Generalization and Specialization

The process of refining one entity types into


subclass types is called specialization.
A top-down process
The process identifying commonalities among
different entity types and define their superclass
type is called generalization.
A bottom-up process
In real world, a database modeling process is
typically mixed.
Slide 12
Condition-Defined Subclasses
 Specialization based on conditions of superclass
attributes.
Example: High-Pay-Male and High-Paid-Female
Drawing
EMPLOYEE

d
salary100000, Sex=M salary100000, Sex=F

High-Pay-Male High-Pay-Female
Slide 13
Discussions

d: means disjoint, each employee can belong to at


most one of the subclass.
 We do not require total participation: an employee may
not be in either class
 A special case of condition-defined specialization is
when the condition is based on the value of a single
attribute
This type specializations is called attribute-defined.

Slide 14
An Attribute-defined Specialization

 Doubled line suggests total participation: an


employee must be either a male or female.

EMPLOYEE

Sex
d
M F

Male-EMP Female-EMP
Slide 15
Attribute Inheritance in Superclass /
Subclass Relationships
 An entity that is member of a subclass inherits
All attributes of the entity as a member of the
superclass
All relationships of the entity as a member of the
superclass
 Example:
SECRETARY inherit the attributes Name, SSN, …,
from EMPLOYEE
SECRETARY can have additional attributes
specific to secretaries (typing speed, …)
Slide 16
Additional attributes in subclasses

Slide 17
Overlapping Specialization
 In an overlapping specialization, indicated by an
circled o, an entity in the superclass can belong to
more than one subclasses.

DEPARTMENT

o
Has a location in DC Has a location in NY

Located-in-DC Located-in-NY
Slide 18
Further Discussions

 A specialization can have only one subclass


 Example: High-Pay-EMP

EMPLOYEE

salary100000


High-Pay-EMP
Slide 19
Summary
Four types of specializations
Total (double-lined), disjoint (d)
Partial (single-lined), disjoint (d)
Total (double-lined), overlapping (o)
Partial (single-lined), overlapping (o)
A subclass may have its own (additional)
attributes
A superclass may have more than one
specialization.

Slide 20
Example of Overlapping Total
Specialization

Slide 21
Multiple Specializations

Slide 22
User-Defined
Specialization/Generalization

 If no condition determines membership, the subclass is called


user-defined
Membership in a subclass is determined by the database
users by applying an operation to add an entity to the
subclass
Membership in the subclass is specified individually for
each entity by the user

 Example: A HANDICAPPED subclass of EMPLOYEE

Slide 23
Specialization/Generalization Hierarchies,
Lattices & Shared Subclasses (1)

 A subclass may itself have further subclasses specified on


it
forms a hierarchy or a lattice
 Hierarchy has a constraint that every subclass has only
one superclass (called single inheritance); this is basically
a tree structure
 In a lattice, a subclass can be subclass of more than one
superclass (called multiple inheritance)

Slide 24
Shared Subclass “Engineering_Manager”

Slide 25
Categories (UNION TYPES)

 With specialization, all subclasses are of the same type


of superclasses.
SECTARY, MANAGER, and HOURLY_EMPLOYEE are all
EMPLOYEEs
 In some cases, we need to superclasses to be of
different entity types
 Such a subclass is called a category or UNION TYPE
A category member must exist in at least one of its
superclasses
Slide 26
Two categories (UNION types): OWNER,
REGISTERED_VEHICLE

Slide 27
28
EER diagram notation to represent
subclasses and specialization

Sir Syed Sarmad


Database Management Systems
Ali Shah
Summary

 Introduced the EER model concepts


Class/subclass relationships
Specialization and generalization
Inheritance
 These augment the basic ER model concepts
introduced in Chapter 3
 EER diagrams and alternative notations were presented

Slide 29

You might also like