• No results found

Subclasses, Superclasses, Inheritance

N/A
N/A
Protected

Academic year: 2020

Share "Subclasses, Superclasses, Inheritance"

Copied!
32
0
0

Loading.... (view fulltext now)

Full text

(1)

EER Diagram

(2)

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 …)

(3)

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.

(4)

Why we need EER modeling?

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 Ali Shah Database Management Systems

(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 Ali Shah

5

(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 Ali Shah

6

(7)

Subclasses and Superclasses (2)

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

Sir Syed Sarmad Ali Shah

7

(8)

Example

Sir Syed Sarmad Ali Shah Database Management Systems

(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 Ali Shah

9

(10)

Slide 10

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

(11)

Slide 11

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

(12)

Slide 12

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

(13)
(14)

Slide 14

Condition-Defined Subclasses

Specialization based on conditions of superclass attributes. Example: High-Pay-Male and High-Paid-Female

Drawing

High-Pay-Male

d

EMPLOYEE

High-Pay-Female

salary≥100000, Sex=F

(15)

Slide 15

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

(16)

Slide 16

An Attribute-defined Specialization

Doubled line suggests total participation: an employee must be either a male or female.

Male-EMP

d

EMPLOYEE

Female-EMP F

M

(17)

Slide 17

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

(18)
(19)

Slide 19

Overlapping Specialization

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

Located-in-DC

o

DEPARTMENT

Located-in-NY

(20)

Slide 20

Further Discussions

A specialization can have only one subclass Example: High-Pay-EMP

High-Pay-EMP EMPLOYEE

salary≥100000

(21)

Slide 21

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

(22)

Slide 22

(23)

Slide 23

(24)

Slide 24

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

(25)

Slide 25

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

(26)

Slide 26

(27)

Slide 27

Categories (UNION TYPES)

With specialization, all subclasses are of the same type of super-classes.

SECTARY, MANAGER, and HOURLY_EMPLOYEE are all EMPLOYEEs

In some cases, we need to super-classes to be of different entity types

Such a subclass is called a category or UNION TYPE

(28)
(29)

Slide 29

Two categories (UNION types): OWNER,

(30)

Difference b/w union and shared subclasses

In EER diagrams union types (categories) are

denoted by placing the letter U inside the circle and

the subset symbol on the line connecting the

subclass with the circle

Differences between union types & shared subclasses

An entity of a shared subclass must exist in all superclasses

An entity of a union type must exist in only one superclass

Entities in shared subclasses inherit attributes of all superclasses

(31)

EER diagram notation to represent subclasses

and specialization

Sir Syed Sarmad Ali Shah Database Management Systems

(32)

Slide 32

Summary

Introduced the EER model concepts Class/subclass relationships

Specialization and generalization Inheritance

These augment the basic ER model concepts introduced in Chapter 3

References

Related documents

This law protects a person with a disability for life This law is what gives students their 504 Plans in school, accommodations in college and employment, and other

Note that an employee performing at this level may not have applied all of the knowledge and skills required to achieve a higher rating OR that the employee may not have yet

It starts with the general entity (superclass) and forms specialized entity types (subclasses) based on specialized attributes or relationships specific to a subclass.. For

For example, in some jurisdictions, an entity may recognise an expense for the consumption of employee services received as consideration for share options granted, in accordance

Employees may pay for the costs of gifts or social events provided by the employee to others, and, provided the employee is not acting on behalf of an IHS entity and does not

- Working with superclasses and subclasses - Adding abstraction to your analysis and design - Understanding the purpose of Java interfaces - Creating and implementing a

Worship Opportunities and Pastoral Care Zion will continue to offer worship services for those willing to come in person as we come into the new church year with Advent

For example, in some jurisdictions, an entity may recognise an expense for the consumption of employee services received as consideration for share options granted, in