The Monoid Comprehension Calculus


There is only one calculus form: the monoid comprehension. It is described in detail in the paper: "Optimizing Object Queries Using an Effective Calculus". It takes the form:

    compr( monoid, head, q1, ..., qn )
where monoid is a monoid name, such as, set, bag, sum, all, some, etc, head is an expression, and q1, ..., qn is a possibly empty list of qualifiers. Each qualifier is either:
  1. a generator of the form iterate(variable,expr), or
  2. a predicate expr.
For example, the OQL query
select distinct struct( E: e.name,
			M: ( select c.name
			     from c in e.children
			    where c.age > 18 ) )
from e in Employees
where e.name = "Smith";
has the following form in the calculus:
compr( set, struct( bind( E, project(e,name) ),
                    bind( M, compr( bag, project(c,name),
                                         iterate(c,project(e,children)),
                                         gt(project(c,age),18) ) ) ),
            iterate(e,Employees),
            eq(project(e,name),"Smith") )


Last modified: 1/20/99 by Leonidas Fegaras