next up previous contents
Next: Insert Queries Up: Syntactic Extensions and Previous: More Implicit Variables

Tuple Attributes

If a class involves tuple attributes then we need a method of grouping together the attributes of a single tuple. For example suppose the schema for the class PERSON had an attribute

  OBJECT CLASS PERSON
    ....
    ATTRIBUTE degree_info (degree_date, degree, field) :
      list-of [1,] ([0,1] DATETIME, [0,1] CHAR(20), [0,1] CHAR(50))
We would like to be able to ask queries such as finding the Persons that had obtained a degree in the field of ``Genetics'' in the year 1980.

We need to extend the definition of variable declarations to allow grouping of variables:

<variable declaration> ::= <variable> IN <class expression>
                         | '(' <variable list> ')' IN 
                              <variable> '.' '(' <projection element list> ')'
                         ;

<variable list> ::= <variable>
                  | <variable list> ',' <variable>
                  ;
<projection element list> ::= <projection element>
                            | <projection element list> ',' <projection element>
                            ;

For example a query to find those people who obtained a degree in Genetics in 1980 would be:

      SELECT X.name
      FROM   X IN PERSON, (Y, Z) IN X.(degree_date, field)
      WHERE  Y MATCH "%1980"
      AND    Z = "Genetics"
      ;

In terms of our relational representation of OPM classes, if a class C has a tuple attribute d with fields then this can be represented by a relation with m+1 attributes, and _oid.

A variable instantiation is then valid for a declaration of the form () IN X.() iff .