Database Reference
In-Depth Information
(SELECT a, b
FROM T1)
DIVIDE
(SELECT b
FROM T2)
Step 6: Find the ON keyword and attributes, if any. None found.
Steps 7 and 8: Is another divide keyword present in either the dividend or divisor? None found.
Step 9: Rewrite the query. A general SQL parser called Zql (Karvounarakis et al., 2002) is used
to extract from the dividend and divisor the select attributes, the from tables, and any where quali-
fiers. The final rewritten query is in Example 1. An analogous process exists for the R2 template
rewrite.
A More Complex Rewrite Example
Input query:
((SELECT a, b, c
FROM T1, T2
WHERE T1.a = T2.a AND T1.b > 0)
Divide
(SELECT b, c
FROM T3, T4
WHERE T3.d = T4.d)
ON {b})
DIVIDE
((SELECT a, d
FROM T1, T2
WHERE T1.a = T2.a AND T1.b < 0)
Divide
(SELECT d, c
FROM T3, T4
WHERE T3.d = T4.d)
ON {d})
ON {a}
*The divide keywords are highlighted for ease of reading.
First found divide query:
(SELECT a, b, c
FROM T1, T2
WHERE T1.a = T2.a AND T1.b > 0)
Divide
(SELECT b, c
FROM T3, T4
WHERE T3.d = T4.d) ON {b}
Dividend: SELECT a, b, c
Search WWH ::




Custom Search