ITPEC FE Morning April 2020 Question 28
A sequence of two relational algebra expressions is shown below.
T1 ← πY(R)
T ← T1 − πY((S × T1) − R)
Here, “πY”, “×”, and “−” represent projection, direct product, and difference, respectively. When the relational states of R and S are as follows, which of the following can be obtained as T?
R
S
Explanation
A only — the two steps are relational division, which keeps the Y values that appear with every X in S.
- •T1 = πY(R): the Y values in R are A and B
- •S × T1: every pairing of X in S with those values gives (1, A), (1, B), (2, A), (2, B)
- •(S × T1) − R: removing the rows of R, (1, A), (2, A) and (2, B), leaves only (1, B), the pairing R lacks
- •πY of that is B, the value missing some X
- •T = T1 − B, which leaves A
A appears with both 1 and 2; B appears only with 2.
Answer (b)
Why not others:
- •(a) NULL — A does pair with every X in S, so the result is not empty
- •(c) B — B is exactly the value removed, since (1, B) is not in R
- •(d) A and B — that is T1 itself, skipping the subtraction of values that miss a pairing
Key rule: R ÷ S = all candidates minus those with some missing pairing: build every combination with S, subtract R, and whatever is left marks the candidates to drop.
Databases · AI-written, may contain errors
This question comes from an official ITPEC past paper. ITPEC Practice is an independent study tool and is not affiliated with ITPEC. See the official FE past-paper collection or Report an issue.