Question

What is the optimized version of the relation algebra expression πA1(πA2(σF1(σF2(r))))\pi_{A1}(\pi_{A2}(\sigma_{F1}(\sigma_{F2}(r)))), where A1,A2A1, A2 are sets of attributes in rr with A1⊂A2A1 \subset A2 and F1,F2F1, F2 are Boolean expressions based on the attributes in rr?

Choose one option
Official answer and solution
Official answer
A
From
Official GATE 2014 answer key

Solution

Apply algebraic transformation rules for cascade of projections and cascade of selections.

Given the relational algebra expression:

E=πA1(πA2(σF1(σF2(r))))E = \pi_{A1}(\pi_{A2}(\sigma_{F1}(\sigma_{F2}(r))))

where A1,A2A1, A2 are sets of attributes with A1⊂A2A1 \subset A2, and F1,F2F1, F2 are selection conditions on attributes of rr.

  1. Cascade of Selections:
    Successive selection operations commute and combine via logical conjunction (AND):

    σF1(σF2(r))=σF1∧F2(r).\sigma_{F1}(\sigma_{F2}(r)) = \sigma_{F1 \land F2}(r).
  2. Cascade of Projections:
    For any attribute sets XX and YY where X⊆YX \subseteq Y:

    πX(πY(R))=πX(R).\pi_X(\pi_Y(R)) = \pi_X(R).

    Since A1⊂A2A1 \subset A2, performing projection onto A2A2 first and then onto A1A1 simply yields the projection onto A1A1 directly:

    πA1(πA2(… ))=πA1(… ).\pi_{A1}(\pi_{A2}(\dots)) = \pi_{A1}(\dots).
  3. Combining both rules:

    E=πA1(σF1∧F2(r)).E = \pi_{A1}(\sigma_{F1 \land F2}(r)).

This matches option A.

Final answer

A

Common trap

Choosing disjunction (OR) instead of conjunction (AND) for cascading selections.

The answer is the one in the official GATE answer key. The solution is this site's own explanation.

Source

Paper
GATE 2014 Computer Science and Information Technology (CS) Session 3
Question
31 of 65, printed as CS Q.21
Section
Computer Science and Information Technology

Report an error in this question

GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.