Databases Reference
In-Depth Information
Attribute 1
Attribute 2
￿
￿
￿
Attribute n
Operation 1
Operation 2
￿
￿
￿
Operation m
message
FIGURE 9.9
An application program sends a message
that triggers an encapsulated operation in
an object
Application Program
Class or Object
A fascinating feature of object-oriented database management that implements
these ideas is called encapsulation . In encapsulation, as illustrated in Figure 9.9, the
attributes of a class' or even an individual object are ''encapsulated,'' stored together
on the disk, with the operations that will act upon them. Yes, the program segments
are actually stored within the database, which is a radical departure from the
complete separation of data and programs that we always assumed in the relational
database environment (as well as in the earlier navigational database environment).
Furthermore, the OODBMS will permit the attributes of the encapsulated objects to
be updated only by the encapsulated update-type operations. New class instances or
objects will be permitted to be created only by the class's encapsulated constructor-
type operations. Query-type operations would also be encapsulated but since they
do not update data, the data integrity issue is not a factor.
When an application program requires encapsulated data for any reason, it
sends a message to one of the object's encapsulated operations to trigger it into
action, Figure 9.9. The application program sends along any input data needed for
the operation (for example, the number of years that an extended warranty is to
be in effect for the Calculate Extended Warranty Price for Power Tools operation
in General Hardware's POWER TOOL class in Figure 9.5). The encapsulated
operation then executes its program code. Depending on the type of operation, it
updates the object's attribute values, adds a new instance of a class or object, or
simply returns data to satisfy a query.
ABSTRACT DATA TYPES
Data has traditionally fitted into one of a small number of simple data types
consisting of a few variations of character and numeric data. These are adequate to
handle the kinds of attributes that we usually think of as being stored in a database.
Names, addresses, descriptions, and so forth are stored as character data types.
Attributes involving money and other numeric data that includes fractional amounts
are stored as decimal numbers. Serial numbers or quantity attributes that count a
number of items are stored as integers. Furthermore, these simple data types have
operations associated with them in the programming languages that use them. We
take it for granted that we can add, subtract, multiply, and divide data stored in the
Search WWH ::




Custom Search