CS FundamentalsHardGATE CS (PYQ pattern)
R(A, B) = {(1,2), (1,3), (2,3), (3,4), (4,1)} is a graph's edge set. How many tuples are in the relation π_{A,D}(ρ(R) ⋈_{R.B = R2.A} ρ(R2)), i.e. the pairs reachable by paths of EXACTLY two edges (R2 is a copy of R with attributes renamed to (A, D))?
- A. 6
- B. 7
- C. 5
- D. 16
Correct answer: A. 6
Joining each edge (a,b) with the edge starting at b gives the two-edge paths [(1, 3), (1, 4), (2, 4), (3, 1), (4, 2), (4, 3)]; duplicates (a,d) are removed by the projection, leaving 6.
More DBMS and SQL questions
- Multiple-granularity locking (modes IS, IX, S, SIX, X with the standard compatibility matrix). T1 holds IX on table TB and S on row r1 of…
- Snapshot isolation with first-committer-wins: a transaction aborts at commit time if some other transaction that committed after it…
- In a wait-for graph over transactions T1..T7 the edges (Ti waits for Tj) are T1→T2, T2→T3, T3→T1, T3→T4, T4→T5, T5→T4, T6→T3, T2→T7…
- Under strict two-phase locking (shared locks for reads, exclusive for writes, all locks held until commit; a transaction whose lock…
- A B+ tree has leaf nodes holding at most 3 keys. Keys are inserted in the order 50, 20, 80, 10, 30, 60, 90, 70, 40, 25, 35, 5, 65, 75, 95…
- A query joins 5 relations R1..R5 and the optimiser considers every possible join tree, including bushy trees, with every distinct…