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?
- A. σ_{amt>100} can be pushed onto Orders before the outer join without changing the result
- B. The selection cannot be evaluated after an outer join at all
- C. Pushing it down is valid only if cid is a key of Customer
- 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
- An ER diagram has Student (key roll, multivalued attribute phone), Course (key cid) and Faculty (key fid). Enrols is many-to-many between…
- R has 2000 tuples with 100 distinct values of attribute b; S has 5000 tuples with 250 distinct values of b. Assuming uniform values and…
- Table Bill(id, cust, region, amt) rows: (1, 'Kavi', 'E', 300), (2, 'Lata', 'W', NULL), (3, 'Kavi', 'E', 450), (4, 'Mona', 'W', 300), (5…
- Table Bill(id, cust, region, amt) rows: (1, 'Kavi', 'E', 300), (2, 'Lata', 'W', NULL), (3, 'Kavi', 'E', 450), (4, 'Mona', 'W', 300), (5…
- Table Bill(id, cust, region, amt) rows: (1, 'Kavi', 'E', 300), (2, 'Lata', 'W', NULL), (3, 'Kavi', 'E', 450), (4, 'Mona', 'W', 300), (5…
- Table Bill(id, cust, region, amt) rows: (1, 'Kavi', 'E', 300), (2, 'Lata', 'W', NULL), (3, 'Kavi', 'E', 450), (4, 'Mona', 'W', 300), (5…