Identification Variables

Home > Query Language > Basic Concepts > Identification Variables

Query languages normally support identification variables: they are declared in the "FROM" clause of a query. These variables may be referenced in other parts of the query, e.g. in the "SELECT" or "WHERE" clauses. For instance, the Java Persistence Query Language distinguishes range variable and collection member declarations.

// p is a range variable; it represents an instance of the person extent
// c is a collection member; it represents a member of the children collection
SELECT p
FROM Person p, IN (p.children) c
WHERE p.firstname = "Roswitha" and c.firstname = "Christian"

Identification variables are indispensable, if path expressions can have different points of origin within the same query. In the example, "p.firstname" starts from a person object whereas "c.firstname" starts from a person's child object; variable names are used to reference these different origins.

OOMEGA does not support identification variables. Why? OOMEGA supports navigation beyond collection-valued fields, i.e. there's no need for the "IN" operator and collection member declarations. In fact, all path expressions can start from the same origin (the object which is currently investigated) and navigate to any field of interest afterwards. If there's only one point of origin available, there's no need to reference it explicitely: hence identification variables are obsolete.

Query(
   from(Person.CID),
   where(
      and(
         eq( P(Person.P.firstname), "Roswitha" ),
         subsetEq( VSet("Christian"), nav( P(Person.P.children), P(Person.P.firstname) )
      )
   )
);

Next chapter: Details of the Query Language

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.