Consider the following three tables 𝑅,𝑆 and 𝑇. In this question, all the…

2015

Consider the following three tables 𝑅,𝑆 and 𝑇.Β In this question, all the join operations are natural joinsΒ (β‹ˆ).Β (πœ‹)Β is the projection operation of a relation:

\(\begin{array}{|ccc|} \hline & R & \\ \hline A && B \\ \hline 1 && 2 \\ 3 && 2 \\ 5 && 6 \\ 7 & &8 \\ 9 && 8 \\ \hline \end{array} \begin{array}{|ccc|} \hline & S & \\ \hline B && C \\ \hline 6 && 2 \\ 2 && 4 \\ 8 && 1 \\ 8 & &3 \\ 2 && 5 \\ \hline \end{array} \begin{array}{|ccc|} \hline & T & \\ \hline A && C \\ \hline 7 && 1 \\ 1 && 2 \\ 9 && 3 \\ 5 & &4 \\ 3 && 5 \\ \hline \end{array}\)

Possible answer tables for this question are also given as below:

\(\underset{\text{(a)}}{\begin{array}{|ccc|} \hline A & B & C \\ \hline 1 & 2& 4 \\ 1 &2& 5 \\ 3 &2& 4 \\ 3 &2& 5 \\ 5 & 6 &2 \\ 7 & 8 & 1 \\ 7 & 8 & 3 \\ 9 & 8 & 1 \\ 9 & 8 & 3 \\ \hline \end{array}} \underset{\text{(b)}}{\begin{array}{|ccc|} \hline A & B & C \\ \hline 1 & 2& 2 \\ 3 &2& 5 \\ 5 &6& 4 \\ 7 &8& 1 \\ 9 & 8 &3 \\ \hline \end{array}} \underset{\text{(c)}}{\begin{array}{|ccc|} \hline A & B & C \\ \hline 1 & 6& 2 \\ 3 &2& 5 \\ 5 &2& 4 \\ 7 &8& 1 \\ 9 & 8 &3 \\ \hline \end{array}} \underset{\text{(d)}}{\begin{array}{|ccc|} \hline A & B & C \\ \hline 3 & 2& 5 \\ 7 &8& 1 \\ 9 & 8 &3 \\ \hline \end{array}}\)

What is the resulting table ofΒ \(πœ‹_{ A,B} (R \bowtie T) \bowtie πœ‹_{B,C} (S \bowtie T)\)Β ?

  1. A.

    (a)

  2. B.

    (b)

  3. C.

    (c)

  4. D.

    (d)

Attempted by 81 students.

Show answer & explanation

Correct answer: A

Solution: follow the specified sequence of natural joins and projections.

  • Step 1: Compute the natural join of R and T on attribute A. Combine matching A values to get (A,B,C) rows: (1,2,2), (3,2,5), (5,6,4), (7,8,1), (9,8,3)

  • Step 2: Project A,B from that result: Ο€_{A,B}(R β‹ˆ T) = (1,2), (3,2), (5,6), (7,8), (9,8)

  • Step 3: Compute the natural join of S and T on attribute C. Combine matching C values to get (A,B,C) rows: (1,6,2), (5,2,4), (7,8,1), (9,8,3), (3,2,5)

  • Step 4: Project B,C from that result: Ο€_{B,C}(S β‹ˆ T) = (6,2), (2,4), (8,1), (8,3), (2,5) (which is the original S).

  • Step 5: Now take the natural join of Ο€_{A,B}(R β‹ˆ T) and Ο€_{B,C}(S β‹ˆ T) on attribute B. This pairs each A,B with every matching B,C to produce the final (A,B,C) rows:

    • (1,2,4)

    • (1,2,5)

    • (3,2,4)

    • (3,2,5)

    • (5,6,2)

    • (7,8,1)

    • (7,8,3)

    • (9,8,1)

    • (9,8,3)

Conclusion: The resulting table is the nine-row table with rows (1,2,4), (1,2,5), (3,2,4), (3,2,5), (5,6,2), (7,8,1), (7,8,3), (9,8,1), (9,8,3).

A video solution is available for this question β€” log in and enroll to watch it.

Explore the full course: Mppsc Assistant Professor