Databases Reference
In-Depth Information
The Lucky Rent-A-Vehicle Class Diagram
Lucky Rent-A-Car has expanded to become Lucky Rent-A-Vehicle! In addition to
renting cars, Lucky is now renting limousines, trucks, airplanes, and helicopters.
The upper part of the Lucky class diagram of Figure 9.8 looks very much like the
Lucky entity-relationship diagram of Figure 2.12. The only difference is the change
from the CAR entity-type to the VEHICLE class.
There is a two-level generalization hierarchy under VEHICLE. At the first
level are the LAND (vehicle) and AIR (vehicle) classes. Then, at the next level
down, a LAND vehicle can be a CAR, LIMOUSINE, or TRUCK, while an AIR
vehicle can be an AIRPLANE or a HELICOPTER. Each CAR object will have nine
attributes: Body Style and Color, plus four attributes inherited from VEHICLE and
another three attributes inherited from LAND. Similarly, each LIMOUSINE will
have nine attributes, each TRUCK will have eight attributes, each AIRPLANE will
have eleven attributes, and each HELICOPTER will have nine attributes.
There is an update operation for all LAND vehicles to update their mileage
attribute that is calculated in the same way for all three types of LAND vehicles;
i.e., there is no polymorphism associated with this operation. On the other hand,
the diagram indicates that there is polymorphism in the way that the Calculate Next
Overhaul Date is inherited downwards from the AIR class to the AIRPLANE and
HELICOPTER classes. The operation will be somewhat different for each of those
two classes.
The diamond-shaped symbol on the branch under the TRUCK class indicates
that there is an aggregation diagram under it. Indeed, each TRUCK is composed of an
ENGINE and a BODY, each with its own attributes. Notice that the company is inter-
ested in keeping data about engines and bodies for trucks but not for cars or limos.
ENCAPSULATION
Earlier, we introduced the concept that it might, in general, be a good idea to permit
particular data to be updated only by a limited, controlled set of program segments.
This would have the advantage of improving data integrity by eliminating the
possibility of some less-than-fully-debugged or otherwise rogue program updating
the data in some inaccurate way. But how can such a concept be implemented?
9.1 G ENERALIZATION /S PECIALIZATION AND A GGREGATION
YOUR
TURN
M any objects in the world can be bro-
ken down into subordinate categories, i.e. ''specialized,''
or, in the opposite direction, ''generalized.'' Other objects
can be created from component parts, i.e. ''aggregated.''
business environment of your choice. Develop an
aggregation diagram for objects in the same business
environment. Can you combine the two diagrams into
one in a way that makes sense?
Q UESTION :
Develop a generalization/specialization diagram for
objects in your university environment or another
Search WWH ::




Custom Search