Previous Table of Contents Next


Here we see that a single data “field” in a table may be a range of values or an entire table. This concept is called complex, or unstructured, data typing (Figure 2.8). The domain of values for a specific field in a relational database may be defined with this approach. This ability to “nest” data tables allows for relationship data to be incorporated directly into the table structure. For example, the Occupation field in the table establishes a one-to-many relationship between an employee and his or her valid occupations. Also note the ability to nest the entire Skills table within a single field. In this example, only valid skills may reside in the Skills field, and this implements the relational concept of “domain integrity.”


Figure 2.8  An example of abstract data types (ADTs).

Definition Of Aggregate Objects

In Oracle8, aggregate objects can be defined and preassembled for fast retrieval. For example, a report_card may be defined for a university database. The report_card object may be defined such that it is assembled at runtime from its atomic components (similar to an Oracle view), or the report_card may be preassembled and stored in the database. These aggregate objects may have methods (such as stored procedures) attached to them, such that an Oracle object couples data and behavior together.

Coupling Of Data And Behavior

The Oracle8 engine allows for the direct coupling of a database entity (a table or object) with a set of predefined behaviors. In this fashion, calls to Oracle will be made by specifying an object name and the method that is associated with the object. For example:

CUSTOMER.add_new('Jones', 123, 'other parms');

This call tells Oracle to invoke the add_new procedure that is attached to the CUSTOMER object, using the supplied parms. As you might expect, this new way of invoking database calls has important ramifications for the developers and DBA staff.

For developers, applications will become SQL-less and will consist of calls to stored procedures. Of course, this has the important benefit of making applications portable across platforms, while also making it very easy to find and reuse code. In addition, since each method is encapsulated and tested independently, the pretested methods can be assembled with other methods without worry of unintended side effects.

For DBAs, the coupling of data with behaviors will dramatically change the way that the DBA performs database administration tasks. Instead of only managing data and tables, the Oracle8 DBA will also be responsible for managing objects and the methods that are associated with each object. These new “object administrator” functions will need to be defined so that the developers know the functions of all methods and all parameters for each method.

Abstraction

Abstraction within Oracle8 is defined as the conceptual (not concrete) existence of classes within the database. For example, a database may have a class hierarchy which includes classes without objects. A military database may contain the conceptual entities of DIVISION, BATTALION, SQUADRON, and PLATOON. The function of the database is to track the platoons, and the entity classes of DIVISION, BATTALION, and SQUADRON may not have any associated objects. This is not to say that abstract classes have no purpose. When a class is defined, it is associated with behaviors, which in turn will be inherited by each object in the PLATOON class. From a database perspective, there will be no instances of any objects except PLATOON, but higher levels in the class hierarchy will contain behaviors which the PLATOON objects inherit.

Inheritance

Inheritance is defined as the ability of a lower-level object to inherit or access the data structures and behaviors associated with all classes that are above it in the class hierarchy. Multiple inheritance refers to the ability of an object to inherit data structures and behaviors from more than one superclass.

To illustrate, let’s look at an application of this system for a vehicle dealership. Occurrences of ITEMs to a dealership are VEHICLEs; beneath the vehicle class, we may find subclasses for cars and for boats. Within cars, the classes may be further partitioned into classes for TRUCK, VAN, and SEDAN. The VEHICLE class would contain the data items which are unique to vehicles, including the vehicle ID and the year of manufacture. The CAR class, because it ISA VEHICLE, would inherit the data items of the VEHICLE class. The CAR class might contain data items such as the number of axles and the gross weight of the vehicle. Because the VAN class ISA CAR, which in turn ISA VEHICLE, objects of the VAN class will inherit all data structures and behaviors relating to CARs and VEHICLEs.


NOTE:  It is critical to the understanding of inheritance to note that inheritance happens at different times during the life of an object.
  Inheritance of Data Structures—At object creation time, inheritance is the mechanism whereby the initial data structure for the object is created. It is critical to note that only data structures are inherited, never data. It is a common misconception that data is inherited, such that an order may inherit the data items for the customer who placed the order. We must understand that inheritance is only used to create the initial, empty data structures for the object. In our example, all vehicles would inherit data definitions in the VEHICLE class, while an object of a lower-level class (say, SAILBOAT) would inherit data structures that apply only to sailboats—as in sail_size.
  Inheritance of Methods—Inheritance also happens at runtime when a call to a method (stored procedure) is made. For example, assume that the following call is made to sailboat object:
    SAILBOAT.compute_rental_charges();

The database will first search for the compute_rental_charges in the SAILBOAT class; if it is not found, the database will search up the class hierarchy until compute_rental_charges is located.


Previous Table of Contents Next