2

Does R ⋈ (S ∪ T) = (R ⋈ S) ∪ (R ⋈ T) hold for relational algebra bag semantics?

I don't know whether this holds for bag semantics for join and union.

philipxy
  • 797
  • 1
  • 7
  • 18

1 Answers1

6

Yes, because multiplication and addition are commutative and associative.

The only difference with bag semantics is that duplicates are preserved.

For rows that join, with rd duplicates in R, sd duplicates in S, and td duplicates in T:

R ⋈ (S ∪ T) gives rd * (sd + td)

(R ⋈ S) ∪ (R ⋈ T) gives (rd * sd) + (rd * td)

The second expression is just the natural algebraic expansion of the first.

The mistake in the second answer linked to is to use set semantics for ∪.

Paul White
  • 94,921
  • 30
  • 437
  • 687