Query by Example
[ Back ] [ Home ] [ Next ]

 

Constraints as Data
Potential Apps
Query by Example
Query by Example
Query by Example
More Examples
Model and Language
Main Features
Hosting Iterative Lang.
Constraint Calculus
Constraint Calculus
Polynomial Complexity
Query Evaluation
Functionality
Optimization
Optimization
Optimization
Optimization
Implemented Apps
Implemented Apps

Query by Example (cont.)

Constraints are also used in CCUBE queries to manipulate, as well as express Boolean conditions on, CST objects. To illustrate, assume that the database stores all_desks of type set(DESK*), i.e., a set of references to object of the class DESK. Consider the following CCUBE query which retrieves all desks that would intersect the room area (3 <= u <= 4 && 8 <= v <= 10), if centered at (6,4) and rotated 30 degrees counter-clockwise relatively to to the room's axes. For each retrieved desk, the query also gives the resulting desk's extent in the room's coordinates. 

       SELECT pair(dsk, ((u,v) | dsk_glob) )
       INTO {Bag<CST*>} result
       FROM all_desks AS {DESK*} dsk
       DEFINE dsk_glob AS {CST} dsk->extent && x == 6 && y == 4 &&
                                                         u == x + cos(30) * w + 0.5 * z &&
                                                         v == y + cos(30) * z + 0.5 * w
       WHERE SAT(3 <= u <= 4 && 8 <= v <= 10 && dsk_glob )

In the FROM clause, the query variable dsk iterates over all_desks. Thus, in the DEFINE, WHERE and SELECT clauses the query variable dsk is bound to (a reference to) an object of the class DESK. In the DEFINE statement, dsk->extent is the extent attribute, which is a CST object in free variables w,z. The DEFINE clause in the example defines a CST object dsk_glob as a symbolic constraint expression (in free variables u,v,x,y,w,z), which is then used in the WHERE and the SELECT clauses. 

In the WHERE clause, SAT is a satisfiability test of the area constraint 3 <= u <= 4 && 8 <= v <= 10 conjuncted with dsk_glob, which finds whether dsk in the room's coordinates intersects the area defined by the constraint (3 <= u <= 4 && 8 <= v <= 10). In the SELECT clause, (u,v) | dsk_glob is the projection of dsk_glob on the room's axes u,v.


presentation created by Victor E. Segal