CS FundamentalsModerateTCS Digital · Infosys SP · GATE CS
Table Stu(sid, sname) rows: (1, 'Om'), (2, 'Pia'), (3, 'Raj'), (4, 'Sia'). Table Takes(sid, cid, marks) rows: (1, 'C1', 80), (1, 'C2', NULL), (2, 'C1', 65), (3, 'C2', 90), (3, 'C3', 75), (5, 'C1', 50). What does this query return?
Table Stu(sid, sname) rows: (1, 'Om'), (2, 'Pia'), (3, 'Raj'), (4, 'Sia').
Table Takes(sid, cid, marks) rows: (1, 'C1', 80), (1, 'C2', NULL), (2, 'C1', 65), (3, 'C2', 90), (3, 'C3', 75), (5, 'C1', 50).
What does this query return?
SELECT COUNT(*) FROM Takes t WHERE t.sid NOT IN (SELECT sid FROM Stu) OR t.marks IS NULL;
- A. 2
- B. 0
- C. 3
- D. 1
Correct answer: A. 2
Stu.sid has no NULLs, so NOT IN works normally: only sid 5 (an orphan row) is missing. Om's C2 row has NULL marks. Two rows.
More DBMS and SQL questions
- Table P(x) rows: (1), (2), (2), (3), (NULL). Table Q(x) rows: (2), (3), (3), (NULL), (4). What does this query return? sql SELECT COUNT()…
- R(A, B, C, D, E) has the set of functional dependencies Σ = {E → BD, AE → C, C → AD}. Which of the following FDs is NOT in Σ⁺ (not implied…
- In a B+ tree every internal node can have at most 50 children and every leaf can hold at most 40 keys. With exactly 3 levels (root at…
- TS(T1) = 15, TS(T2) = 30, TS(T3) = 25; all read/write timestamps start at 0. Under basic timestamp ordering with Thomas's write rule…
- R(A, B, C, D, E) with functional dependencies B → AD, AC → B, A → B is decomposed into R1(A, B), R2(B, D), R3(B, C, E). Which statement is…
- R(A, B, C, D, E, F) has functional dependencies A → CD, CF → A, E → B, D → A. Which of these attribute sets is NOT a superkey of R?