Databases Reference
In-Depth Information
discussion, we briefly characterize the difference between the two concepts
as follows. Inheritance is a reusability mechanism that allows a class to be
defined from another class, by possibly extending and/or modifying the
superclass definition. Instead, a type T is a subtype of a type T
¢
if an instance
of T can be used wherever an instance of T
is used. Therefore, subtyping is
characterized by a set of rules ensuring that no type violations occur when the
instance of a subtype T is used in place of an instance of a supertype of T.
Note that the fact that a class C is a subclass of a class C
¢
¢
does not necessarily
imply that C is also a subtype of C
. For example, to reuse common attrib-
utes and methods (name, address, telephone, e-mail, fax, etc.), a class com-
pany can be defined as a subclass of the class person. It is obvious that, by
contrast, the company type cannot be a subtype of the person type; in such
a case, the subclassing is just a reusability mechanism. Subtyping, however,
influences inheritance, because it may restrict the overriding and impose con-
ditions on multiple inheritance, so that the subtyping rules are not violated.
An example of restriction on overriding is to require that, when the domain
of an attribute is redefined in a subclass, the domain be a subclass of the
domain associated to the attribute in the superclass. A discussion of inheri-
tance and subtyping is presented in [11].
¢
7.3
Graphical Notation and Example
An object-oriented database schema can be represented as a graph. In such a
representation, a node (denoted by a box) represents a class. A class node
contains the names of all instance attributes and methods. The latter are
underlined. Finally, the class-attributes (and methods) are distinguished
from the instance-attributes (and methods) by enclosing them in an ellipse.
Nodes can be connected by three types of arc. An arc from class C to C
¢
denotes different relationships between the two classes, depending on the arc
type. A normal arc (i.e., nonbold and nonhatched) indicates that C
¢
is the
domain of an attribute A of C, or that C
is the domain of the result of
a method M of C. A bold arc indicates that C is the superclass of C
¢
.A
hatched arc indicates that C is the class of an input parameter for some
method M of C
¢
.
An example is presented in Figure 7.2. We assume that in the Team
class there is a method, project-budget. This method is applied to a team
and receives as input parameter a project; the method output is an integer
that represents the amount of budget allocated by the team on the project.
Moreover, we assume that a class-attribute, called maximum-salary, is
¢
Search WWH ::




Custom Search