1. University MCA (AI/ML) Semester 2
  2. CAB206
  3. Unit 3

CAB206 · Unit 3: OLAP and SQL for BI

OLAP cube operations and ROLAP, MOLAP, HOLAP

9 practice questions

Key points

  • Roll-up aggregates up; drill-down adds detail
  • Slice fixes one dimension; dice restricts two or more
  • Pivot rotates the view
  • ROLAP relational, MOLAP array, HOLAP hybrid
  • ROLLUP gives n+1 grouping sets, CUBE gives 2^n

OLAP (online analytical processing) lets users explore data as a multidimensional cube: measures (sales, quantity) viewed along dimensions (time, product, region). Dimensions have hierarchies (Year > Quarter > Month; Country > State > City).

Core operations

  • Roll-up (drill-up): aggregate to a higher level of a hierarchy (city to state) or remove a dimension.
  • Drill-down: move to finer detail (year to quarter to month).
  • Slice: fix one dimension to a single value (year = 2024), producing a sub-cube with one fewer dimension.
  • Dice: select values or ranges on two or more dimensions, producing a smaller sub-cube.
  • Pivot (rotate): swap rows and columns to view the data from a different angle.

Storage architectures

  • ROLAP: relational tables with SQL generated on the fly. Scales to large data, slower for complex aggregates.
  • MOLAP: multidimensional arrays with pre-computed aggregates. Very fast, but limited size and needs a load step.
  • HOLAP: hybrid; aggregates in a cube, detail in relational tables.

SQL support. GROUP BY ROLLUP(a,b,c) returns subtotals up a hierarchy: (a,b,c), (a,b), (a), and the grand total, so n + 1 grouping sets. GROUP BY CUBE(a,b,c) returns every combination: 2^n grouping sets (8 for three columns). GROUPING SETS lets you list the sets explicitly.

Cuboids. With n dimensions and no hierarchies a full cube has 2^n cuboids. With hierarchies, the count is the product of (levels + 1) over the dimensions. Cells in a cube with an "ALL" value per dimension: product of (members + 1).

Try two questions

Question 1 · Tier 2, Understand

Which operation selects values on two or more dimensions to form a smaller sub-cube (for example, two regions and one product)?

  1. Slice
  2. Drill-through
  3. Dice
  4. Roll-up
Show the answer

C. Dice restricts several dimensions at once; slice restricts one.

Question 2 · Tier 3, Apply

How many grouping sets does GROUP BY ROLLUP(year, quarter, month) produce, including the grand total?

  1. 6
  2. 3
  3. 8
  4. 4
Show the answer

D. ROLLUP over n columns gives n + 1 sets: (year,quarter,month), (year,quarter), (year) and ().