SQL & Queries



Answer & solution
Answer: V={(1,3),(1,4),(2,5)}. (no official key was published)
The view combines a tuple (u,v) in the first copy of R with a tuple (v,w) in the second and returns (u,w), so it enumerates two-edge paths. For R={(1,2),(2,3),(2,4),(4,5),(6,7),(6,8),(9,10)}, the paths 1→2→3 and 1→2→4 yield (1,3),(1,4), while 2→4→5 yields (2,5). No other second component matches a first component. Thus V contains exactly those three tuples. They are distinct, so SQL bag semantics and set semantics give the same contents for this instance.