The GATE Grind

GATE 2025 DA – Question 46

Database Management and Warehousing · Data warehouse modelling and OLAP · 2 marks · Multiple choice

Consider a fact table in an OLAP application: $Facts(D1, D2, val)$, where $D1$ and $D2$ are its dimension attributes and $val$ is a dependent attribute. Suppose attribute $D1$ takes 3 values and $D2$ takes 2 values, and all combinations of these values are present in the table $Facts$. How many tuples are there in the result of the following query?

SELECT D1, D2, sum(val)
FROM Facts
GROUP BY CUBE (D1, D2);
  1. 1
  2. 6
  3. 9
  4. 12

Practise this question in The GATE Grind →

Show answer and explanation

Correct answer: (D) 12

Explanation

`GROUP BY CUBE (D1, D2)` computes the grouping for every subset of the two attributes. Grouping by (D1, D2) gives $3 \times 2 = 6$ rows, by D1 alone 3 rows, by D2 alone 2 rows, and the grand total 1 row. The result has $6 + 3 + 2 + 1 = 12$ tuples.