CS FundamentalsHardProduct placement · SQL round
Table Staff(id, name, dept, pay, boss) rows: (1, 'Anu', 'Ops', 40, NULL), (2, 'Bala', 'Ops', 55, 1), (3, 'Chitra', 'Tech', 70, 1), (4, 'Dev', 'Tech', NULL, 3), (5, 'Esha', NULL, 35, 3), (6, 'Farid', 'Tech', 70, 2). What does this query return?
Table Staff(id, name, dept, pay, boss) rows: (1, 'Anu', 'Ops', 40, NULL), (2, 'Bala', 'Ops', 55, 1), (3, 'Chitra', 'Tech', 70, 1), (4, 'Dev', 'Tech', NULL, 3), (5, 'Esha', NULL, 35, 3), (6, 'Farid', 'Tech', 70, 2).
What does this query return?
SELECT name FROM Staff WHERE id NOT IN (SELECT boss FROM Staff);
- A. Anu, Dev, Esha, Farid
- B. Dev, Esha, Farid
- C. Anu
- D. No rows (empty result)
Correct answer: D. No rows (empty result)
The subquery returns a NULL (Anu has no boss). x NOT IN (..., NULL) is never TRUE — it is FALSE or UNKNOWN — so no row qualifies. NOT EXISTS would give Dev, Esha, Farid.
More DBMS and SQL questions
- R(A, B, C, D, E, F) has the set of functional dependencies Σ = {E → ABF, F → BE, C → F, B → C}. Which of the following FDs is NOT in Σ⁺…
- R(A, B, C, D, E, F) has functional dependencies C → AD, A → D, D → C. What is the highest normal form R satisfies?
- Consider the schedule R2(B), R2(C), W3(A), W1(B), R1(C), W1(C), R3(B). Which statement is correct?
- A multilevel index is built over a first level of 90,000 index entries; every index block holds 45 entries (fan-out 45), and levels are…
- Which statement about the expressive power of query languages is correct?
- R is decomposed into R1 and R2. Which condition guarantees the decomposition is lossless?