CS FundamentalsHardGATE CS · Product-company placement

Skill(emp, sk) has rows (r, sql), (r, py), (r, go), (s, sql), (s, py), (t, sql), (t, go), (t, py), (t, c). Req(sk) has rows (sql), (py), (go). Which employees does this query return? SELECT DISTINCT emp FROM Skill s WHERE NOT EXISTS (SELECT * FROM Req r WHERE NOT EXISTS (SELECT * FROM Skill s2 WHERE s2.emp = s.emp AND s2.sk = r.sk));

  1. A. r only
  2. B. t only
  3. C. r and t
  4. D. r, s and t

Correct answer: C. r and t

The double NOT EXISTS is relational division: keep an employee if no required skill is missing. r and t have all of sql, py and go (t's extra skill c does not matter); s lacks go.

More DBMS and SQL questions

Exams that ask this topic