Skip to content
Official PYQ · 2014

GATE CS 2014 Set 3 Q21 — Relational Model: Relational Algebra

Explain with AI

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
View worked solution

Answer: A

To optimize the given relational algebra expression, we can apply standard heuristic optimization rules for relational algebra:

1. Selection Cascading (Combining Selections):
Consecutive selection operations can be combined into a single selection using the logical AND (wedge\\wedge) operator: sigmaF1(sigmaF2(r))equivsigmaF1wedgeF2(r)\\sigma_{F1}(\\sigma_{F2}(r)) \\equiv \\sigma_{F1 \\wedge F2}(r) This reduces the number of passes or evaluations needed for filtering rows.

2. Projection Cascading (Eliminating Redundant Projections):
For nested projection operations piX(piY(R))\\pi_{X}(\\pi_{Y}(R)), if the set of attributes XX is a subset of YY (XsubseteqYX \\subseteq Y), then the intermediate projection onto YY is redundant because the outer projection onto XX will ultimately discard any extra attributes in YY.
Given that A1subsetA2A1 \\subset A2, we have: piA1(piA2(R))equivpiA1(R)\\pi_{A1}(\\pi_{A2}(R)) \\equiv \\pi_{A1}(R) Applying this to our expression where R=sigmaF1wedgeF2(r)R = \\sigma_{F1 \\wedge F2}(r) gives: piA1(piA2(sigmaF1wedgeF2(r)))equivpiA1(sigmaF1wedgeF2(r))\\pi_{A1}(\\pi_{A2}(\\sigma_{F1 \\wedge F2}(r))) \\equiv \\pi_{A1}(\\sigma_{F1 \\wedge F2}(r))

Thus, the optimized relational algebra expression is piA1(sigma(F1wedgeF2)(r))\\pi_{A1}(\\sigma_{(F1 \\wedge F2)}(r)), which corresponds to Option A.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Relational Model: Relational Algebra questions