CS FundamentalsVery hardGATE CS

Customer(cid, city) LEFT OUTER JOIN Orders(oid, cid, amt) on cid is followed by the selection amt > 100. An optimiser wants to push this selection down. Which statement is correct?

  1. A. σ_{amt>100} can be pushed onto Orders before the outer join without changing the result
  2. B. The selection cannot be evaluated after an outer join at all
  3. C. Pushing it down is valid only if cid is a key of Customer
  4. D. Pushing it below the join keeps customers with no qualifying orders as NULL-padded rows, which the original query removes, so the rewrite is wrong

Correct answer: D. Pushing it below the join keeps customers with no qualifying orders as NULL-padded rows, which the original query removes, so the rewrite is wrong

After the join, σ_{amt>100} rejects NULL-padded rows, so the query is effectively an inner join. Pushing the selection onto Orders first and then outer-joining would bring those customers back with NULLs; the correct rewrite turns the outer join into an inner join and then pushes the selection.

More DBMS and SQL questions

Exams that ask this topic