next up previous contents
Next: Expressions Up: Select Queries Previous: Select Queries

Semantics in Relational Model Terms

We will attempt to make the semantics of the query language more precise by describing how it would be interpreted in an underlying representation of an OPM database in the relational model.

Suppose that C is an object class with single valued attributes and set or list valued attributes . For simplicity we will assume that C is represented by m+1 relations: a relation C with attributes _oid and , and for each set-valued attribute, , a relation with attributes _oid and .

Note that, in practice, the representation of classes will be more complicated than this because of inheritance, and because of the presense of tuple attributes. However the relationships mentioned above could be formed as joins and projections on the actual relationships used to represent a class.

We assume a distinguished value Null which will be used to represent unbound variables.

A valid instantiation for a FROM statement is then an assignment of a value to each variable declared in the FROM statement such that:

  1. if the FROM statement contains a declaration Y IN C or Y IN X.a[ C] then either or ;
  2. if the FROM statement contains a declaration of the form Y IN X.[ C], where is a single-valued attribute, then ;
  3. if the FROM statement contains a declaration of the form Y IN X.[ C], where is a set-valued attribute, then either or ; and
  4. if then either the FROM statement contains a declaration of the form Y IN X.[ C] where or , or the FROM statement contains a declaration Y IN X.[ C] where or .

Example. Suppose we had an object class

   OBJECT CLASS Person
     ATTRIBUTE name: [0,1] String
     ATTRIBUTE children: set-of [0,] String
and in an instance the class was represented by the table Person:

and the table Person:

and that a query has the FROM statement

	FROM X IN Person, Y IN X.name, Z IN X.children
Then the valid instantiations of X, Y and Z are given by:



next up previous contents
Next: Expressions Up: Select Queries Previous: Select Queries