The GATE Grind

GATE 2014 CS (CS3) – Question 31

Databases · Relational Model: Relational Algebra, Tuple Calculus, SQL · 1 mark · Multiple choice

Optimize $\pi_{A_1}(\pi_{A_2}(\sigma_{F_1}(\sigma_{F_2}(r))))$, where $A_1\subset A_2$ are attribute sets of r and $F_1,F_2$ are Boolean expressions on its attributes.

  1. $\pi_{A_1}(\sigma_{F_1\land F_2}(r))$
  2. $\pi_{A_1}(\sigma_{F_1\lor F_2}(r))$
  3. $\pi_{A_2}(\sigma_{F_1\land F_2}(r))$
  4. $\pi_{A_2}(\sigma_{F_1\lor F_2}(r))$

Practise this question in The GATE Grind →

Show answer and explanation

Correct answer: (A) $\pi_{A_1}(\sigma_{F_1\land F_2}(r))$

Explanation

Consecutive selections require both predicates, so combine them with F1∧F2. Since A1⊂A2, projecting ontoA2thenA1is equivalent to projecting directly ontoA1. The result is **π_A1(σ_(F1∧F2)(r)),A**. Disjunction would admit additional rows.