-1

enter image description here

I have difficulty in understanding how does the bag union operates in relational algebra?

Here, 1) has a schema (X, Y, A) 2) (Y, A) 3) (X, A) 4) (Y, A) so how will output look like after union operation on 1, 2, 3, and 4? In my understanding for union operation schema should be the same but here 2 output of 4 has a different schema.

ANS: C

3
  • Are you allowed to extend 2,3,4 with an attribute? Feb 24, 2020 at 15:14
  • No, have a look at answer I posted.
    – ssp4all
    Feb 24, 2020 at 21:59
  • 1
    And the definition you were given for bag union is what? And why do you think that will be the output, justifying by referring to the definition? And where are you 1st stuck doing that? PS Use text, not image/links, for what can we expressed via text. PS There is no standard bag algebra or bag union, so you need to give your definition of union & your algebra anyway.
    – philipxy
    May 3, 2020 at 3:27

1 Answer 1

2

After giving this question little thoughts, I found, I was missing the projection part which means the only attribute A is considered for the union. So, basically all we have to do is grouping using GAMMA and then select attribute A and perform union.

Derivation:

  1. \gamma(x,y,avg(z)) => {(2,6,5),(5,6,3),(9,0,4)}

renaming avg(z) to A and projecting that column results in:

{5,3,4}

Remaining 2,3 and 4 with the same method then becomes:

  1. {11,8}
  2. {5,1,1}
  3. {5,9}

So we end up with the bag:

{5,3,4, 11,8, 5,1,1 ,5,9}

Clearly statement a, b and d is False and statement c is True

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.