Machine-translated by Google. Questions are authored in English.
Top

Discussion

Consider a relational database schema with two relations R(P, Q) and S(X, Y).

Let \[ \begin{aligned} E = \{\langle u\rangle \mid\ & \exists v\, \exists w\ \langle u, v\rangle \in R \\ & \wedge \langle v, w\rangle \in S\} \end{aligned} \] be a tuple relational calculus expression.

Which one of the following relational algebraic expressions is equivalent to E ?

  • A.\(\Pi_{P}(R \bowtie_{R.P=S.X} S)\)
  • B.\(\Pi_{P}(S \bowtie_{S.X=R.Q} R)\)
  • C.\(\Pi_{P}(R \bowtie_{R.P=S.Y} S)\)
  • D.\(\Pi_{P}(S \bowtie_{S.Y=R.Q} R)\)

Answer: B

The equivalent expression is \(\Pi_{P}(S \bowtie_{S.X=R.Q} R)\).

E returns each u such that some tuple \(\langle u, v\rangle\) is in R and some tuple \(\langle v, w\rangle\) is in S. The shared variable v is R's second attribute Q and S's first attribute X, so the join condition is R.Q = S.X, and the result keeps u, which is R.P.

Joins are commutative, so writing S first does not matter. The other options join on R.P, S.Y or a different pairing, each linking the wrong attributes: R.P = S.X matches u with S's first attribute, and S.Y = R.Q links v to S's second attribute.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.