CS FundamentalsVery hardTCS Digital · Infosys
Ed(a, b) holds the edges (1, 2), (2, 3), (3, 1), (3, 4). How many rows does the following return? WITH RECURSIVE p(n, d) AS (SELECT 1, 0 UNION ALL SELECT b, d + 1 FROM Ed JOIN p ON a = n WHERE d < 4) SELECT COUNT(*) FROM p
- A. 6
- B. 4
- C. 5
- D. 8
Correct answer: A. 6
The rows are (1,0), (2,1), (3,2), then (1,3) and (4,3), then (2,4) from (1,3); (3,5) is not produced because d < 4 fails for d = 4. Total 6.
More DBMS and SQL questions
- The set F = {A -> BC, B -> C, A -> B, AB -> C} on R(A, B, C) is given. How many functional dependencies are there in a minimal (canonical)…
- Basic timestamp ordering is used with timestamps TS(T1) = 1, TS(T2) = 2, TS(T3) = 3. The schedule on one item A is R2(A), W3(A), R1(A)…
- Relation R has 1,000 tuples with 100 distinct values of attribute A, and S has 500 tuples with 50 distinct values of A, all of which…
- A B+ tree is built so that every node is completely full: a leaf holds 100 keys and an internal node has 101 children. It indexes…
- R(A, B, C, D, E) has the functional dependencies AB -> C, C -> D, D -> E and E -> A. How many candidate keys does R have?
- Consider the schedule R1(A), W2(A), W1(A), W3(A). Which statement is correct?