CS FundamentalsVery hardTCS Digital · Infosys SP · GATE CS
Table P(x) rows: (1), (2), (2), (3), (NULL). Table Q(x) rows: (2), (3), (3), (NULL), (4). What does this query return?
Table P(x) rows: (1), (2), (2), (3), (NULL).
Table Q(x) rows: (2), (3), (3), (NULL), (4).
What does this query return?
SELECT (SELECT COUNT(*) FROM (SELECT x FROM P UNION SELECT x FROM Q)),
(SELECT COUNT(*) FROM (SELECT x FROM P INTERSECT SELECT x FROM Q)),
(SELECT COUNT(*) FROM (SELECT x FROM P EXCEPT SELECT x FROM Q));- A. 4, 2, 1
- B. 5, 2, 2
- C. 10, 3, 1
- D. 5, 3, 1
Correct answer: D. 5, 3, 1
Set operations remove duplicates and treat NULLs as identical. UNION = {1, 2, 3, 4, NULL} (5); INTERSECT = {2, 3, NULL} (3); EXCEPT = {1} (1).
More DBMS and SQL questions
- R(A, B) = {(1, 4), (2, 4), (3, 3), (4, 1), (4, 3)} and S(B, C) = {(1, 6), (2, 5), (2, 6), (3, 5), (4, 5)}. How many tuples are in πA(R ⋈…
- Table Staff(id, name, dept, pay, boss) rows: (1, 'Anu', 'Ops', 40, NULL), (2, 'Bala', 'Ops', 55, 1), (3, 'Chitra', 'Tech', 70, 1), (4…
- R(A, B, C, D, E) has functional dependencies B → AC, C → B, AC → B, A → B. How many prime attributes does R have?
- Table Stu(sid, sname) rows: (1, 'Om'), (2, 'Pia'), (3, 'Raj'), (4, 'Sia'). Table Takes(sid, cid, marks) rows: (1, 'C1', 80), (1, 'C2'…
- A B+ tree index uses 4096-byte blocks, 20-byte search keys, 12-byte block (tree) pointers and 14-byte record pointers. What is the maximum…
- For the schedule W1(C), W2(C), R2(B), R3(A), W4(C), R4(C), R3(B), R1(B), how many serial schedules of T1–T4 are conflict-equivalent to it?