Database Reference
In-Depth Information
(SELECT [A∩B]
FROM [T2] AS y
WHERE NOT EXISTS
(SELECT [A∩B]
FROM [T1] AS z
WHERE (z.[A-B]=x.[A-B]) AND (z.[A∩B]=y.[A∩B])));
However, it was discovered early on in this research project that R1 suffers from two important flaws:
if T1 or T2 or both consist of more than one table, this template fails; the second is that the where-clauses
of T1 and T2 collide with the template's where-not-exists clauses. That is why R2 is used instead.
R2: SELECT DISTINCT x.[A-B]
FROM (SELECT [A-B]
FROM [T1]
WHERE [W1]) AS x
WHERE NOT EXISTS
(SELECT *
FROM (SELECT [A∩B]
FROM [T2]
WHERE [W2]) AS y
WHERE NOT EXISTS
(SELECT *
FROM (SELECT [A∩B]
FROM [T1]
WHERE [W1]) AS z
WHERE (z.[A-B]=x.[A-B]) AND (z.[A∩B]=y.[A∩B])));
In R2, both the dividend and the divisor are each encased within a from statement which uses an
alias to maintain the x-y-z relationship. Complete SQL statements may be retained in the dividend and
divisor clauses. This is a highly impractical solution to the query rewrite problem because now there are
six select statements. However, the classic rewrite is not intended as a solution to this project, rather it
serves as the comparison query against R0.
Divide-On Grammar
Consider a scenario where the dividend is known and the divisor is not entirely known. Such a divisor
might be a stored query, a view, or a table where SELECT * is used but division is not desired across
all of its attributes. Even more common might be that the SELECT * is desired, but the attributes are
not in a compatible order with those of the dividend. A way to refine or limit which attributes to divide
on is desired.
The second form of the proposed divide grammar is
Search WWH ::




Custom Search