Databases Reference
In-Depth Information
A 1
A 2
B 1
B 2
B 3
C 1
C 2
C 3
a3
l ink
b2
link
l ink2
c2
v
l ink2
a3
link
b2
link
link2
c1
t
link2
a2
l ink
b2
link
l ink2
c2
v
l ink2
a2
link
b2
link
link2
c1
t
link2
Now let us add the DISTINCTROW keyword and select a single column from just tblA:
SELECT DISTINCTROW A1
FROM
(Temp1 INNER JOIN Temp2 ON Temp1.A2 = Temp2.B2)
INNER JOIN Temp3 ON Temp2.B3 = Temp3.C3;
Now we consider the projection onto the rows of the only return table (tblA):
A 1
A 2
a3
l ink
a3
link
a2
l ink
a2
link
It is clear that the first two rows of this table are the same row of tblA, so they produce
only one row in the final result table. The same holds for the last two rows. Hence, the
result table is:
A 1
a2
a3
Let us now change this by requesting a column from tblC, thus making it a return table as
well:
SELECT DISTINCTROW A1,C1
FROM
(Temp1 INNER JOIN Temp2 ON Temp1.A2 = Temp2.B2)
INNER JOIN Temp3 ON Temp2.B3 = Temp3.C3;
The projection onto return table rows is now:
A 1
A 2
C 1
C 2
C 3
a3
link
c 2
v
l ink2
a3
link
c1
t
link2
a2
link
c 2
v
l ink2
a2
link
c1
t
link2
These row “pairs” are all distinct. In fact:
Search WWH ::




Custom Search