What Is OLAP

OLAP (Online Analytical Processing) lets analysts look at warehouse data quickly from many points of view. Where OLTP records day-to-day transactions, OLAP answers questions such as "What were the sales of each category in each city in each month?" The term was introduced by E. F. Codd.

Characteristics of OLAP

  • Multidimensional view: data is seen as a cube with dimensions such as product, store and time.
  • Fast, interactive analysis: answers come in seconds, so the user can keep asking follow-up questions.
  • Summarised and historical data with hierarchies (day, month, quarter, year).
  • Read-mostly access: users query and rarely update.
  • Support for complex calculations such as ratios, growth and ranking.

Architecture

A typical OLAP system has three tiers: the bottom tier is the warehouse database server with ETL tools; the middle tier is the OLAP server; the top tier is the front end with query, reporting and analysis tools.

Efficient Processing of OLAP Queries

Speed comes from pre-computing common summaries (materialised cuboids), indexing (bitmap and join indexes), partitioning large tables and caching results. The query is answered from the smallest summary that contains the answer.

OLAP Server Architectures

  • ROLAP (Relational OLAP): data stays in relational tables and multidimensional queries are translated into SQL. It scales to very large data but is slower.
  • MOLAP (Multidimensional OLAP): data is stored in multidimensional arrays. It is very fast, but sparse data wastes space and size is limited.
  • HOLAP (Hybrid OLAP): detailed data stays relational while summaries are kept as arrays, giving a balance.

Definition: OLAP. A technique for the fast, interactive analysis of summarised, multidimensional data stored in a data warehouse.

Table 1.2: OLTP compared with OLAP

Point OLTP OLAP
Purpose Day-to-day transactions Analysis and decisions
Data Current, detailed Historical, summarised
Users Clerks, many Managers, analysts, few
Operations Insert, update, short reads Complex reads, aggregation
Database design Normalised (ER) Star or snowflake
Size Megabytes to gigabytes Gigabytes to terabytes

Example 1.2: Storage of MOLAP and ROLAP

Problem: A cube has 100 products, 50 stores and 365 days, so 100 x 50 x 365 cells. Only 2 percent of the cells contain a sale. A MOLAP array uses 8 bytes per cell; a ROLAP table stores only non-empty cells at 20 bytes per row. Compare the storage.

Solution:

  1. Total cells = 100 x 50 x 365 = 1,825,000.
  2. MOLAP stores every cell: 1,825,000 x 8 = 14,600,000 bytes.
  3. Non-empty cells = 2 percent of 1,825,000 = 36,500.
  4. ROLAP stores only these: 36,500 x 20 = 730,000 bytes.

Result: ROLAP needs 730,000 bytes against 14,600,000 for MOLAP, 20 times less, because the cube is sparse.

cells = 100 * 50 * 365
molap = cells * 8
rows = int(cells * 0.02)
rolap = rows * 20
print("Cells        :", cells)
print("MOLAP bytes  :", molap)
print("Non-empty    :", rows)
print("ROLAP bytes  :", rolap)
print("Ratio        :", molap // rolap)

Output

Cells        : 1825000
MOLAP bytes  : 14600000
Non-empty    : 36500
ROLAP bytes  : 730000
Ratio        : 20

Common mistakes

  • Treating OLAP as a replacement for the warehouse; it is an access layer on top of it.
  • Choosing MOLAP for very large sparse data.
  • Running heavy analysis queries on the OLTP database.
  • Forgetting that OLAP data is mostly read-only and summarised.

Key takeaways

  • OLAP gives fast multidimensional analysis of warehouse data.
  • Three tiers: warehouse server, OLAP server, front end.
  • ROLAP uses tables, MOLAP uses arrays, HOLAP mixes both.
  • OLTP is for transactions; OLAP is for analysis.

Practice questions

  1. What does OLAP stand for?
  2. Which OLAP type stores data in arrays?
  3. Why is MOLAP wasteful for sparse data?

Answers to the practice questions

  1. Online Analytical Processing.
  2. MOLAP.
  3. It allocates space for every cell, even empty ones.

Sources

  • Official BCA syllabus Data Warehousing and Mining, course code 25BCA406DS03, Unit I