Database Reference
In-Depth Information
D0: SELECT DISTINCT x.A
FROM T1 AS x
WHERE NOT EXISTS
(SELECT *
FROM T2 AS y
WHERE NOT EXISTS
(SELECT *
FROM T1 AS z
WHERE (z.A=x.A) AND (z.B=y.B)));
D1 is an alternate formulation which is simpler to implement (Brantner et al., 2007). It uses mem-
bership test, group-by , counting, and having SQL constructs, yet computationally it is much faster (less
table scanning) and closer semantically to the division in relational algebra.
D1: SELECT A
FROM T1
WHERE B IN
(SELECT B
FROM T2)
GROUP BY A
HAVING COUNT(*) =
(SELECT COUNT (*)
FROM T2);
PROPOSED SQL DIVIDE GRAMMARS
In this study, two SQL relational division grammars are proposed and each is examined to determine
the minimum number of keywords needed to implement.
First SQL Divide Grammar
The first form of the proposed divide grammar is
G1: (table1) DIVIDE (table2)
G1a: (SELECT i..j,r..s,t..v FROM table1 WHERE …) DIVIDE
(SELECT r..s FROM table2 WHERE …)
This divide grammar is a departure from that posited by Rantzau (Harris & Shadbolt, 2005) because
this paper assumes a complete SQL query may be contained within each of the dividend and divisor
clauses. This is possible as long as the projection of the final dividend relation contains an ordered set
of attributes which is a superset of the projection of the final divisor relation's attributes.
Search WWH ::




Custom Search