Oracle’s object model is like the class system found in C++, Microsoft .NET, and Java. This allows for a real object-oriented architecture to be implemented in the database. Complicated real-life entities and logic can be modeled easily while allowing the reuse of objects that make developing database applications faster and more efficient (Oracle, 2002d, p. 1). Application developers can directly access Oracle object types without the need for any additional layers between the database and the client. Instances of objects types can be placed in the database as rows in tables or as values in columns (Oracle, 2002b, p. 1). Additionally, applications using Oracle’s object types are easier to understand and maintain because Oracle’s object types fully support the object-oriented characteristics of abstraction and encapsulation of object behaviors.
While database tables contain data only, objects in Oracle have the capability to act upon the data in various ways. For example, an application can call an exposed method of an object to retrieve detailed information. A couple simple examples of how this may work is described in the Oracle literature,
A purchase order object might include a method to sum the cost of all the
items purchased. Or a customer object might have methods to return the
customer name, reference number, address, or even his buying history and
payment pattern (Oracle, 2002d, p. 2).
This functionality would be encapsulated within each object and consequently provides for great efficiencies. Since object types and their methods are stored inside the database they can be accessed by any application. This can reduce and in some cases eliminate the need for every application that is using the database to re-code similar structures (Oracle, 2002d, p. 2). New applications can simply use the existing functionality.
Being able to fetch and manipulate related objects as one unit creates even more efficiencies. An application can fetch a single object that in turn retrieves additional objects that are connected to the object being fetched. For example, a request for a customer object can be given. In a single round trip between the client and the server, the customer’s name, phone number, and the multiple parts of the address can be returned (Oracle, 2002d, p. 2).
By using Oracle object types part-to-whole relationships can be more easily created. For example, trying to represent a wheel as a part of a car would be difficult in a relational system where part-to-whole relationships can only be accomplished by creating complex schemas of multiple tables (Oracle, 2002d, p. 2). By using object types, objects can have other objects as attributes. This relationship can be extended even further with each subsequent object attribute having other objects as attributes. As a result of establishing interconnected object types, object hierarchies can be established in an Oracle database.
Another advantage of using objects in Oracle is the ability to easily determine if an entity is complete by looking at the entity’s parts. This can be more easily explained by looking at an example of an address. An address object is made up of street name, street number, city, sate, and zip code. If values for any of these attributes are missing then the address object can know that it is not complete. In contrast, a relational table cannot be designed to recognize that all the columns in the table jointly make up a whole (Oracle, 2002d, p. 2).
Oracle object types allows for object type inheritance, meaning a new object subtype can be derived from a parent type definition. Similarities between the types can be shared while characteristics can be extended for the inheriting object (Oracle, 2002b, p.1). For example, a motorcycle or a car subtype could be created from a general vehicle supertype object inheriting the features of this vehicle type. The specialized object types of motorcycle and car can contain additional attributes or redefined methods of the parent object type vehicle extending their object type functionality.


No comments:
Post a Comment