This module explored the performance implications of object-oriented features that were introduced in Oracle beginning with Oracle 8i.
This module explored the performance implications of the exciting new object-oriented features introduced in Oracle.
The main points of this module include:
- Abstract data type (ADT) is great for grouping related data columns together and reusing them in many Oracle tables.
- Oracle allows for OIDs to be datatypes. You can create a column in a table that contains the OIDs of other tables.
- Getting data from other tables is achieved by de-referencing the OID. This uses the DEREF syntax.
- The DEREF command displays the contents of the row that corresponds with the OID.
- De-referencing an OID is far faster than joining tables together, and requires less disk I/O and fewer block reads.
- Because Oracle uses the term OID to mean an Object ID, or the Oracle Internet Directory, be careful when reading the Oracle documentation.
Oracle allows for the definition of repeating data types. These data types can be inserted into tables, avoiding the need to join tables together.
Rather than rebuild the Oracle engine as an object-oriented architecture, Oracle has decided to keep the base relational engine and add object functionality on top of the standard relational architecture. While claiming to be an active member in the Object Management Group (OMG), Oracle has departed from the OMG's standard for "pure" object databases as defined by the Object Data Management Group
. Oracle's intent is to provide a generic relational database while extending the architecture to allow for objects.
The object layer of Oracle offers the following features:
- abstract data typing,
- definition of aggregate objects,
- coupling of data and behavior,
- encapsulation, and
In an object table, each row is a row object. An object table differs from a normal relational table in several ways.
- First, each row within the object table has an OID, an object identifier value assigned by Oracle when the row is created.
- Second, the rows of an object table can be referenced by other objects within the database.
You can create an object table via the create table command. Consider the ANIMAL_TY datatype shown in previous chapters.
To avoid conflicts with objects created during earlier chapters, create this type in a new schema:
create or replace type ANIMAL_TY as object
To keep this example simple, the ANIMAL_TY datatype is created without any member functions.
To create an object table of the ANIMAL_TY datatype, issue the following create table command:
create table ANIMAL of ANIMAL_TY;
Note that the command has an unusual syntax, creating the table of an object type. The resulting table may first appear to be a normal relational table:
The ANIMAL table's columns map to the attributes of the ANIMAL_TY object type. However, there are significant differences in how you can use the table, since it is an object table.
As noted earlier in this section, each row within the object table will have an OID value, and the rows can be referenced as objects.
Here are some terms that may be new to you:
- Object ID:A unique identifier for an object.
- Pointer: A variable or reference that holds address information and points or refers to a location (usually in another table).
- VARRAY:Is a repeating group that allows us to dramatically improve the performance of Oracle queries, because subordinate tables are no longer required in order to represent a one-to-many relationship.
The next module discusses using the Oracle Dictionary to monitor performance.