Skip to main content

GATE CSE 2024Databases › Relational Algebra & CalculusVerified

GATE CSE 2024 PYQ: Consider the following two relations, R ( A , B ) R(A, B) R ( A , B ) and S ( A , C ) S(A, C) S ( A , C ) :…

Consider the following two relations, R(A,B)R(A, B) and S(A,C)S(A, C):
RAB10202030304030505095SAC109030454080 \begin{array}{|c|} \hline \textbf{R} \\ \hline \begin{array}{c|c} \textbf{A} & \textbf{B} \\ \hline \text{10} & \text{20} \\ \hline \text{20} & \text{30} \\ \hline \text{30} & \text{40} \\ \hline \text{30} & \text{50} \\ \hline \text{50} & \text{95} \end{array} \\ \hline \end{array} \quad \begin{array}{|c|} \hline \textbf{S} \\ \hline \begin{array}{c|c} \textbf{A} & \textbf{C} \\ \hline \text{10} & \text{90} \\ \hline \text{30} & \text{45} \\ \hline \text{40} & \text{80} \\ \end{array} \\ \hline \end{array}
The total number of tuples obtained by evaluating the following expression

σB<C(R⋈R.A=S.AS)\sigma_{B<C}\left(R \bowtie_{R . A=S . A} S\right) is ___________.

    Answer

    2

    Approach

    Evaluate the expression inside-out: first perform the equipjoin of R and S on their common attribute A (matching R.A with S.A), producing tuples over (A, B, C). Then apply the selection condition $σ_{B\&lt;C} \text{to keep only those joined tuples where} B \text{is strictly less than} C,$ and count the survivors.

    The join produces 3 tuples sharing A values 10 and 30; the filter B&lt;C removes only the tuple (30,50,45) since 50 is not less than 45. Hence the expression returns exactly 2 tuples.

    Reviewed by GateIQ Editorial Team: IIT & IISc Alumni.