Query Table

Problem 1

Construct a query control for relational table T. T has cardinality N. K is a list of the key fields in T, and F is a list of the data fields.

The control should have four components:


The user should be able to construct the "select <fields> from t" part of a query interactively. Once fields have been selected, the user should be able to specify which of the key fields, if any, the resulting view is to be grouped on. If grouping has been specified, the user should also be able to indicate, for each data field in the view, what aggregation function is to be used.


The user should be able to construct the "where" clause from binary expressions involving the key fields. These clauses ought to be reasonably expressive, involving at least conjunction and disjunction of elementary relational expressions.


The user should be able to see the SQL (or SQL-like) query implied by his selections.


The view of t implied by the query should be visible. The user should be able to sort the view on different fields.




Project, Restrict:

Group, Aggregate:

Problem 2

Extend the solution to use T to restrict the transaction table U. U has key *!U, date field (!U)1, and value field (!U)2.




Project, Restrict: