Relational Algebra – Bag Union Operation

relational-algebraunion

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

Best Answer

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