168k views
2 votes
Suppose a relation R(A,B) has 4 tuples (1,2), (2,1), (1,3), (2,4). A result of γA,SUM(B) -> SumOfB(R) is __________

Select one:
a. A relation has 3 tuples (2,5), (5,1)
b. A relation has 4 tuples (1,2), (2,3), (1,1), (2,4)
c. None of the others
d. A relation has 2 tuples (1,5), (2,5)

User Daaku
by
8.2k points

1 Answer

2 votes

Final answer:

The result of the relational algebra operation γA,SUM(B) -> SumOfB(R) on the given relation R(A,B) is a new relation with two tuples: (1,5) and (2,5), representing the sum of values in attribute B for each distinct value in attribute A.

Step-by-step explanation:

The question refers to a relational algebra operation known as grouping and aggregation. Specifically, it uses the gamma (γ) operator for aggregation. In the provided relation R(A,B), the operation γA,SUM(B) -> SumOfB(R) is used togroup the tuples based on attribute A and sum the values of attribute B for each group.

The tuples (1,2), (2,1), (1,3), (2,4) are grouped by A, resulting in two groups: one for A=1 and another for A=2. For A=1, the sum of B is 2+3=5, and for A=2, the sum of B is 1+4=5. Therefore, we get two tuples as the result of the aggregation: (1,5) and (2,5).

The correct answer is: A relation has 2 tuples (1,5), (2,5).

User Zveratko
by
8.1k points