Database1 Lecture3
Database1 Lecture3
Database1 Lecture3
Superclass An entity type that includes one or more distinct subgroupings of its occurrences, which
require to be represented in a data model.
Subclass A distinct subgrouping of occurrences of an entity type, which require to be represented in a
data model.
An entity in a subclass represents the same ‘real world’ object as in the superclass, and may possess
subclass-specific attributes, as well as those associated with the superclass.
We say that an entity that is a member of a subclass inherits all the attributes of the entity as a member of the
superclass. The entity also inherits all the relationships in which the superclass participates.
SPECIALIZATION
Specialization: The process of maximizing the differences between members of an entity by identifying
their distinguishing characteristics.
is the process of defining a set of subclasses of an entity type; this entity type is called the superclass of the
specialization
The 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
GENERALIZATION
Participation constraint: Determines whether every member in the superclass must participate as a
member of a subclass.
a double line to connect the superclass to the circle is used to display a total specialization.
A single line is used to display a partial specialization,
Disjoint constraint: Describes the relationship between members of the subclasses and indicates
whether it is possible for a member of a superclass to be a member of one, or more than one,
subclass.
the d in the circle stands for disjoint.
The o in the circles stands for overlapping
SPECIALIZATION AND GENERALIZATION HIERARCHIES AND
LATTICES
A subclass itself may have further subclasses specified on it, forming a hierarchy or a lattice of
specializations.
A specialization hierarchy has the constraint that every subclass participates as a subclass in only one
class/subclass relationship; that is, each subclass has only one parent, which results in a tree structure
or strict hierarchy.
In contrast, for a specialization lattice, a subclass can be a subclass in more than one class/subclass
relationship.
SPECIALIZATION AND GENERALIZATION HIERARCHIES AND
LATTICES
In such a specialization lattice or hierarchy, a subclass inherits the attributes not only
of its direct superclass, but also of all its predecessor super classes all the way to the
root of the hierarchy or lattice if necessary.
an entity may exist in several leaf nodes of the hierarchy, where a leaf node is a class
that has no subclasses of its own.
A subclass with more than one superclass is called a shared subclass
SPECIALIZATION AND GENERALIZATION HIERARCHIES AND
LATTICES
Multiple inheritance, where the shared subclass directly inherits attributes and
relationships from multiple classes.
Notice that the existence of at least one shared subclass leads to a lattice (and hence
to multiple inheritance); if no shared subclasses existed, we would have a hierarchy
rather than a lattice and only single inheritance would exist.
EXAMPLE
1. The database keeps track of three types of persons: employees, alumni, and students. A person can belong to one, two,
or all three of these types. Each person has a name, SSN, sex, address, and birth date.
2. Every employee has a salary, and there are three types of employees: faculty, staff, and student assistants. Each
employee belongs to exactly one of these types. For each alumnus, a record of the degree or degrees that he or she
earned at the university is kept, including the name of the degree, the year granted, and the major department. Each
student has a major department.
3. Each faculty has a rank, whereas each staff member has a staff position. Student assistants are classified further as
either research assistants or teaching assistants, and the percent of time that they work is recorded in the database.
Research assistants have their research project stored, whereas teaching assistants have the current course they work
on.
4. Students are further classified as either graduate or undergraduate, with the specific attributes degree program (M.S.,
Ph.D., M.B.A., and so on) for graduate students and class (freshman, sophomore, and so on) for undergraduates.
UTILIZING SPECIALIZATION AND GENERALIZATION IN REFINING
CONCEPTUAL SCHEMAS
Specialization process
Start with entity type then define subclasses by successive specialization
Top-down conceptual refinement process
Many specializations and subclasses can be defined to make the conceptual model accurate
If subclass has few specific attributes and no specific relationships
Can be merged into the superclass
If all the subclasses of a specialization/generalization have few specific attributes and no specific
relationships
Can be merged into the superclass
Replace with one or more type attributes that specify the subclass or subclasses that each entity belongs to
DESIGN CHOICES FOR SPECIALIZATION/GENERALIZATION
(CONT’D.)
Possible approaches:
Foreign key approach
Choose one of the relations—S, say—and include as a foreign key in S the primary key of T. It is better to choose an entity type with
total participation in R in the role of S.
Measures of quality
Making sure attribute semantics are clear
Reducing redundant information in tuples
Reducing NULL values in tuples
Disallowing possibility of generating spurious tuples
IMPARTING CLEAR SEMANTICS TO ATTRIBUTES IN RELATIONS
Semantics of a relation
Meaning resulting from interpretation of attribute values in a tuple
Design base relation schemas so that no update anomalies are present in the
relations
If any anomalies are present:
Note them clearly
Make sure that the programs that update the database will operate correctly
NULL VALUES IN TUPLES
Avoid placing attributes in a base relation whose values may frequently be NULL
If NULLs are unavoidable:
Make sure that they apply in exceptional cases only, not to a majority of tuples
GENERATION OF SPURIOUS TUPLES
NATURAL JOIN
Result produces many more tuples than the original
set of tuples in EMP_PROJ
Called spurious tuples
Represent spurious information that is not valid
GUIDELINE 4
Design relation schemas to be joined with equality conditions on attributes that are
appropriately related
Guarantees that no spurious tuples are generated
Avoid relations that contain matching attributes that are not (foreign key, primary
key) combinations
DESIGN IS
The art or action of conceiving of and producing a plan or drawing of something before it is made.
The arrangement of the features of an artefact, as produced from following a plan or drawing.
Questions?