QBE is a DML whose query language:
The QBE system displays "skeleton tables" - relations with just the attributes (column headers of the tables). The user specifies a query by filling in fields of one or more skeleton tables.
Microsoft Access supports a (very nonstandard) variant of QBE.
Quel is the original query language for the Ingres database system. It is based on tuple relational calculus.
Basic form of queries:
range of
t is
r
range of
t is
r
...
range of
t is
r
retrieve
(t.A , t.A , ..., t.A )
where
P
This is equivalent to the trc query:
t t r t
r t r
P
t[A t[A
t[A t[A
...
t[A t[A
except that the predicate P would be slightly different.
Examples:
Find the name and address of all customers who have purchased a flyrod with flyrod-stock-num of 3.
range of
t is
customer
range of
s is
purchased
retrieve
(t.name, t.address)
where
t.cust-num = s.cust-num and
s.flyrod-stock-num = 3
Find the name and address of everyone with the same address as Tim Wahls.
range of
t is
customer
range of
s is
customer
retrieve
(t.name, t.address)
where
s.name = "Tim Wahls" and
s.address = t.address
Quel also has aggregate functions:
count
, sum
, avg
, max
,
min
, countu
, sumu
, avgu
,
any
Function any
is related to count
- it always
returns 0 when count
would return 0, and 1 when
count
would return a number larger than 0.
Example: Find the average length of all flyrods stocked by the flyshop that are not 9 weights.
range of
t is
flyrod
retrieve avg
(t.length where not
(t.line-weight = 9))