0% found this document useful (0 votes)
25 views66 pages

5.CSI2004-ADBMS_Module1__EER2

Uploaded by

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

5.CSI2004-ADBMS_Module1__EER2

Uploaded by

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

CSI2004 - Advanced Database

Management Systems
Extended E-R Model
Extended E-R Features
 Extended ER is a high-level data model that
incorporates the extensions to the original ER
model.
 Enhanced ER models are high level models
that represent the requirements and
complexities of complex databases.
 The extended E-R features are
 Specialization
 Generalization
 Aggregation
Specialization
 Top-down design process: The process of designating
subgroupings within an entity set is called
specialization.
 These subgroupings become lower-level entity sets that
have attributes or participate in relationships that do not
apply to the higher-level entity set.
 Depicted by a triangle component labeled ISA (E.g.
customer “is a” person).
 The ISA relationship also referred to as superclass -
subclass relationship
 Attribute inheritance – a lower-level entity set inherits
all the attributes and relationship participation of the
higher-level entity set to which it is linked.
Specialization Example
Specialization Example

• In terms of an E-R
diagram, specialization is
depicted by a hollow
arrow-head pointing
from the specialized entity
to other entity
• We refer to this
relationship as the ISA
relationship, which stands
for “is a” and represents,
for example, that an
instructor “is a”
employee
1/3/2025 5:39:56 6
PM
Specialization Example

• Higher- and lower-level entity sets also may be


designated by the terms superclass and
subclass, respectively.

• The person entity set is the superclass of the


employee and student subclasses

1/3/2025 5:39:56 7
PM
Specialization Example

1/3/2025 5:39:56 8
PM
Specialization Example

• Specialization process allows us to do the


following:
•Define a set of subclasses of an entity type
•Establish additional specific attributes with
each subclass
•Establish additional specific relationship
types between each subclass and other
entity types or other subclasses

1/3/2025 5:39:56 9
PM
Representing Specialization via
Schemas
 Method 1:
 Form a schema for the higher-level entity
 Form a schema for each lower-level entity set, include
primary key of higher-level entity set and local attributes
schema attributes
person ID, name, street, city
student ID, tot_cred
employee ID, salary

 Drawback: getting information about, an employee


requires accessing two relations, the one corresponding
to the low-level schema and the one corresponding to the
high-level schema
Representing Specialization via Schemas
 Method 2:
 Form a schema for each entity set with all local
and inherited attributes

schema attributes
person ID, name, street, city
student ID, name, street, city, tot_cred
employee ID, name, street, city, salary

 Drawback: name, street and city may be stored


redundantly for people who are both students and
employees
Generalization

 A bottom-up design process: – combine a number


of entity sets that share the same features into a
higher-level entity set.
 Specialization and generalization are simple
inversions of each other; they are represented in an
E-R diagram in the same way.
 The terms specialization and generalization are
used interchangeably.

12
Generalization
• The database designer may have first identified:
• instructor entity set with attributes instructor id,
instructor name, instructor salary, and rank.
• secretary entity set with attributes secretary id,
secretary name, secretary salary, and hours per week.
• There are similarities between the instructor entity set
and the secretary entity set in the sense that they have
several attributes that are conceptually the same across
the two entity sets: namely, the identifier, name, and
salary attributes.
• This commonality can be expressed by generalization,
which is a containment relationship that exists between a
higher-level entity set and one or more lower-level entity
sets.
1/3/2025 5:39:56 13
PM
Generalization
Design Constraints on a
Specialization/Generalization

 Constraint on which entities can be members


of a given lower-level entity set.
 condition-defined
Example: all customers over 65 years are
members of senior-citizen entity set;
senior-citizen ISA person.
 user-defined
Design Constraints on a
Specialization/Generalization

 Constraint on whether or not entities may belong


to more than one lower-level entity set within a
single generalization.
 Disjoint
an entity can belong to only one lower-level
entity set
 Overlapping
an entity can belong to more than one
lower-level entity set
Design Constraints on a
Specialization/Generalization

 Disjointness Constraint:
 Specifies that the subclasses of the
specialization must be disjoint:
an entity can be a member of at most one of
the subclasses of the specialization
 Specified by d in EER diagram
 If not disjoint, specialization is overlapping:
that is the same entity may be a member of
more than one subclass of the specialization
 Specified by o in EER diagram
Design Constraints on a
Specialization/Generalization

EER diagram notation


for an attribute-defined
specialization on
Job_type.
Design Constraints on a
Specialization/Generalization

EER diagram notation for an overlapping (nondisjoint)


specialization.
Attribute Inheritance

 A crucial property of the higher- and lower-level


entities created by specialization and generalization
is attribute inheritance.
 The attributes of the higher-level entity sets are said
to be inherited by the lower-level entity sets.
 For example, student and employee inherit the
attributes of person
Attribute Inheritance
A higher-level entity set with attributes and
relationships that apply to all of its lower-level entity
sets.
 Lower-level entity sets with distinctive features that
apply only within a particular lower-level entity set
 In a hierarchy, a given entity set may be involved as
a lower-level entity set in only one ISA relationship;
that is, entity sets in this diagram have only single
inheritance.
 If an entity set is a lower-level entity set in more than
one ISA relationship, then the entity set has multiple
inheritance, and the resulting structure is said to be a
lattice
Design Constraints on a
Specialization/Generalization

 Completeness constraint -- specifies whether or not


an entity in the higher-level entity set must belong to at
least one of the lower-level entity sets within a
generalization.
 Total : an entity must belong to one of the lower-
level entity sets
 Partial: an entity need not belong to one of the
lower-level entity sets

22
Design Constraints on a
Specialization/Generalization

 Completeness Constraint:
 Total specifies that every entity in the
superclass must be a member of some subclass
in the specialization/generalization
 Shown in EER diagrams by a double line
 Partial allows an entity not to belong to any
of the subclasses
 Shown in EER diagrams by a single line
Design Constraints on a
Specialization/Generalization
 Partial generalization is the default. We can specify total
generalization in an ER diagram by adding the keyword
total in the diagram and drawing a dashed line from the
keyword to the corresponding hollow arrow-head to
which it applies (for a total generalization), or to the set of
hollow arrow-heads to which it applies (for an
overlapping generalization).
 The student generalization is total: All student entities
must be either graduate or undergraduate. Because the
higher-level entity set arrived at through generalization is
generally composed of only those entities in the lower-
level entity sets, the completeness constraint for a
generalized higher-level entity set is usually total
Design Constraints on a
Specialization/Generalization

 In general, a superclass that was identified


through the generalization process usually
is total, because the superclass is derived
from the subclasses and hence contains
only the entities that are in the subclasses
Design Constraints on a
Specialization/Generalization

 Disjointness and completeness constraints are


independent
 Four possible constraints on specialization:
 Disjoint, total
 Disjoint, partial
 Overlapping, total
 Overlapping, partial
Design Constraints on a
Specialization/Generalization
Design Constraints on a
Specialization/Generalization
Aggregation
 One limitation of the E-R model - It cannot express relationships
among relationships.
Example-1
Aggregation

1/3/2025 5:40:51 30
PM
Aggregation

ER Diagram with Aggregation


Aggregation
Example-2

 Consider the ternary relationship proj_guide, which we saw


earlier
 Suppose we want to record evaluations of a student by a guide
on a project
Aggregation
 Relationship sets eval_for and proj_guide represent
overlapping information
 Every eval_for relationship corresponds to a proj_guide
relationship
 However, some proj_guide relationships may not
correspond to any eval_for relationships
So we can’t discard the proj_guide relationship

 Eliminate this redundancy via aggregation


 Treat relationship as an abstract entity
 Allows relationships between relationships
 Abstraction of relationship into new entity
Aggregation
 Eliminate this redundancy via aggregation without introducing
redundancy, the following diagram represents:
 A student is guided by a particular instructor on a particular
project
 A student, instructor, project combination may have an
associated evaluation
Representing Aggregation via Schemas

 To represent aggregation, create a schema containing


 Primary key of the aggregated relationship,
 The primary key of the associated entity set
 Any descriptive attributes
 In our example:
 The schema eval_for is:
eval_for (s_ID, project_id, i_ID, evaluation_id)
 The schema proj_guide is redundant.
Symbols used in the E-R notation
Symbols used in the E-R notation
Symbols used in the E-R notation .

1/3/2025 5:39:56 38
PM
Alternative ER Notations
Alternative ER Notations

Chen IDE1FX
(Crows feet notation)
Example
Example:
Subclasses and Superclasses

 An entity type may have additional meaningful


subgroupings of its entities
 Example: EMPLOYEE may be further 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

 EER diagrams extend ER diagrams to represent these


additional subgroupings, called subclasses or subtypes
Subclasses and Superclasses
Subclasses and Superclasses

 Each of these subgroupings 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:
 EMPLOYEE/SECRETARY
 EMPLOYEE/TECHNICIAN
 EMPLOYEE/MANAGER
 …
Representing Specialization in EER
Diagrams
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:
 In the previous slide, SECRETARY (as well as
TECHNICIAN and ENGINEER) inherit the
attributes Name, SSN, …, from EMPLOYEE
 Every SECRETARY entity will have values for
the inherited attributes
Specialization

 Specialization is the process of defining a set of


subclasses of a superclass
 The set of subclasses is based upon some
distinguishing characteristics of the entities in the
superclass
 Example: {SECRETARY, ENGINEER,
TECHNICIAN} is a specialization of
EMPLOYEE based upon job type.
May have several specializations of the
same superclass
Specialization

 Example: Another specialization of EMPLOYEE based on


method of pay is {SALARIED_EMPLOYEE,
HOURLY_EMPLOYEE}.
 Superclass/subclass relationships and specialization can
be diagrammatically represented in EER diagrams
 Attributes of a subclass are called specific or local
attributes.
For example, the attribute TypingSpeed of
SECRETARY
 The subclass can also participate in specific relationship
types.
For example, a relationship BELONGS_TO of
HOURLY_EMPLOYEE
Specialization
Generalization

 Generalization is the reverse of the specialization


process
 Several classes with common features are
generalized into a superclass;
 original classes become its subclasses
 Example: CAR, TRUCK generalized into
VEHICLE;
 both CAR, TRUCK become subclasses of the
superclass VEHICLE.
 We can view {CAR, TRUCK} as a specialization
of VEHICLE
 Alternatively, we can view VEHICLE as a
generalization of CAR and TRUCK
Generalization
Generalization and Specialization

 Diagrammatic notation are sometimes used to


distinguish between generalization and
specialization
 Arrow pointing to the generalized superclass
represents a generalization
 Arrows pointing to the specialized subclasses
represent a specialization
 We do not use this notation because it is often
subjective as to which process is more
appropriate for a particular situation
 We advocate not drawing any arrows
Generalization and Specialization

 Data Modeling with Specialization and


Generalization
 A superclass or subclass represents a
collection (or set or grouping) of entities
 It also represents a particular type of entity
 Shown in rectangles in EER diagrams (as are
entity types)
 We can call all entity types (and their
corresponding collections) classes, whether
they are entity types, superclasses, or
subclasses
Constraints on Specialization and
Generalization
 If all subclasses in a specialization have membership
condition on same attribute of the superclass,
specialization is called an attribute-defined
specialization
 Attribute is called the defining attribute of the
specialization
 Example: JobType is the defining attribute of the
specialization {SECRETARY, TECHNICIAN,
ENGINEER} of EMPLOYEE
 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 in the superclass by the user
Displaying an attribute-defined
specialization in EER diagrams
Example of disjoint partial Specialization
Example of overlapping total Specialization
Specialization/Generalization Hierarchies,
Lattices & Shared Subclasses

 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)
Specialization/Generalization Hierarchies,
Lattices & Shared Subclasses

Shared Subclass “Engineering_Manager”


Specialization/Generalization Hierarchies,
Lattices & Shared Subclasses

 In a lattice or hierarchy, a subclass inherits attributes not


only of its direct superclass, but also of all its predecessor
superclasses
 A subclass with more than one superclass is called a shared
subclass (multiple inheritance)
 Can have:
 specialization hierarchies or lattices, or
 generalization hierarchies or lattices,
 depending on how they were derived
 We just use specialization (to stand for the end result of
either specialization or generalization)
Specialization/Generalization Hierarchies,
Lattices & Shared Subclasses

 In specialization, start with an entity type and then


define subclasses of the entity type by successive
specialization
 called a top down conceptual refinement process
 In generalization, start with many entity types and
generalize those that have common properties
 Called a bottom up conceptual synthesis process
 In practice, a combination of both processes is
usually employed
Specialization / Generalization Lattice
Example (UNIVERSITY)
Categories (UNION TYPES)

 All of the superclass/subclass relationships we


have seen thus far have a single superclass
 A shared subclass is a subclass in:
 more than one distinct superclass/subclass
relationships
 each relationships has a single superclass
 shared subclass leads to multiple inheritance
 In some cases, we need to model a single
superclass/subclass relationship with more than
one superclass
 Superclasses can represent different entity types
 Such a subclass is called a category or UNION
Categories (UNION TYPES)

 Example: In a database for vehicle registration, a


vehicle owner can be a PERSON, a BANK (holding a
lien on a vehicle) or a COMPANY.
 A category (UNION type) called OWNER is created to
represent a subset of the union of the three superclasses
COMPANY, BANK, and PERSON
 A category member must exist in at least one of its
superclasses
 Difference from shared subclass, which is a:
 subset of the intersection of its superclasses
 shared subclass member must exist in all of its
superclasses
Two categories (UNION types): OWNER,
REGISTERED_VEHICLE

You might also like