GATE / CS ARCHIVE

GATE CSE 2002 / QUESTION 17(b)(ii)

Incremental self-join view after two inserted tuples

Database Management Systems · SQL & Queries · Full GATE CSE 2002 paper

GATE 2002, Q17(b)(ii) Descriptive
Report issue

SQL & Queries

Question 17(b)(ii), GATE 2002: R(A,B)={(1,2),(2,3),(2,4),(4,5),(6,7),(6,8),(9,10)}. View V is SELECT R1.A,R2.B FROM R R1,R R2 WHERE R1.B=R2.A. Original17(b)(ii): Insert(2,11),(11,6) into R. Which additional tuples enter V?
Question 17(b)(ii), GATE 2002: R(A,B)={(1,2),(2,3),(2,4),(4,5),(6,7),(6,8),(9,10)}. View V is SELECT R1.A,R2.B FROM R R1,R R2 WHERE R1.B=R2.A. Original17(b)(ii): Insert(2,11),(11,6) into R. Which additional tuples enter V?
Question 17(b)(ii), GATE 2002: R(A,B)={(1,2),(2,3),(2,4),(4,5),(6,7),(6,8),(9,10)}. View V is SELECT R1.A,R2.B FROM R R1,R R2 WHERE R1.B=R2.A. Original17(b)(ii): Insert(2,11),(11,6) into R. Which additional tuples enter V?
Question 17(b)(ii), GATE 2002: R(A,B)={(1,2),(2,3),(2,4),(4,5),(6,7),(6,8),(9,10)}. View V is SELECT R1.A,R2.B FROM R R1,R R2 WHERE R1.B=R2.A. Original17(b)(ii): Insert(2,11),(11,6) into R. Which additional tuples enter V?
Tap to enlarge
Answer & solution

Answer: Additional tuples: {(1,11),(2,6),(11,7),(11,8)}. (no official key was published)

Let ΔR={(2,11),(11,6)}. A newly created length-two path must use at least one new edge, so inspect R⋈ΔR, ΔR⋈R, and ΔR⋈ΔR. The existing edge 1→2 followed by 2→11 adds (1,11). The new edge 11→6 followed by existing 6→7 or 6→8 adds (11,7),(11,8). The two new edges together form 2→11→6 and add (2,6). These four tuples are the additions; the original three remain. Longer paths such as 1→2→11→6 do not qualify, because this view joins exactly two copies of R rather than taking a transitive closure.

Original paper, page 9