next up previous contents
Next: Query Rewriting Up: Processing Select Queries Previous: Processing Select Queries

Method Based Query Processing

Representing OPM classes using relational DBMS constructs entails representing not only class definitions using relations and constraints, but also retrieval and update methods using SQL procedures (see [3]).

A retrieval method for a class involves SQL procedures representing retrieval methods for each attribute A of : procedures for non-derived attributes consist of simple selections from the primary or auxiliary relation containing the relational attribute representing A; procedures for derived attributes consist of computing their values using arithmetic expressions, aggregate functions, or a sequence of joins (for composition derived attributes). The retrieval method for a class consists of combining the retrieval methods for the attributes of .

The retrieval methods mentioned above can be used for retrieving the values of all the attributes mentioned in the select and where statements of the OPM query. Subsequently, a query processor external to the DBMS can be used for evaluating the query conditions and for selecting the instances that satisfy these conditions.

Consider the following query for finding the names of persons owning a fragment that is also owned by John:

     SELECT X.name
     FROM   X IN PERSON, J IN PERSON, 
            XF IN X.owns[FRAGMENT], JF IN J.owns[FRAGMENT]
     WHERE  J.name = "John"
     AND    XF = JF
     ;
Using retrieval methods, the values of all attributes for all instances of class FRAGMENT can be retrieved; using the retrieval method for attribute name of class PERSON, the values of derived (composition) attribute owner.name can be retrieved; finally, for each FRAGMENT instance x, the query processor verifies whether the owner.name value for x matches ``John''.

Using retrieval methods has the advantage of being simple and complying with the object-oriented principle of encapsulation. However, this approach can be slow if only a small number of instances in the target class satisfy the query condition. For example, if there are only a few fragments that satisfy the condition of the query then using retrieval methods for processing the query will result in first retrieving all fragments and then examining them one by one.



next up previous contents
Next: Query Rewriting Up: Processing Select Queries Previous: Processing Select Queries