Lecture 10 More OLAP Dimensional modeling www cl

  • Slides: 18
Download presentation
Lecture 10: More OLAP - Dimensional modeling www. cl. cam. ac. uk/Teaching/current/Databases/ 1

Lecture 10: More OLAP - Dimensional modeling www. cl. cam. ac. uk/Teaching/current/Databases/ 1

Conceptual Modeling of Data Warehouses Modeling data warehouses: dimensions & measures – Star schema:

Conceptual Modeling of Data Warehouses Modeling data warehouses: dimensions & measures – Star schema: A fact table in the middle connected to a set of dimension tables – Snowflake schema: A refinement of star schema where some dimensional hierarchy is normalized into a set of smaller dimension tables, forming a shape similar to snowflake – Fact constellations: Multiple fact tables share dimension tables, viewed as a collection of stars, therefore called galaxy schema or fact constellation 2

Star 3

Star 3

Star Schema 4

Star Schema 4

Terms • Fact table • Dimension tables • Measures 5

Terms • Fact table • Dimension tables • Measures 5

Another Star Schema time item time_key day_of_the_week month quarter year Sales Fact Table time_key

Another Star Schema time item time_key day_of_the_week month quarter year Sales Fact Table time_key item_key branch_key branch_name branch_type location_key units_sold dollars_sold avg_sales item_key item_name brand type supplier_type location_key street city province_or_street country Measures 6

Dimension Hierarchies s. Type store city region èsnowflake schema èconstellations 7

Dimension Hierarchies s. Type store city region èsnowflake schema èconstellations 7

Cube Fact table view: Multi-dimensional cube: dimensions = 2 8

Cube Fact table view: Multi-dimensional cube: dimensions = 2 8

3 -D Cube Fact table view: Multi-dimensional cube: day 2 day 1 dimensions =

3 -D Cube Fact table view: Multi-dimensional cube: day 2 day 1 dimensions = 3 9

Aggregates • Add up amounts for day 1 • In SQL: SELECT sum(amt) FROM

Aggregates • Add up amounts for day 1 • In SQL: SELECT sum(amt) FROM SALE WHERE date = 1 81 10

Aggregates • Add up amounts by day • In SQL: SELECT date, sum(amt) FROM

Aggregates • Add up amounts by day • In SQL: SELECT date, sum(amt) FROM SALE GROUP BY date 11

Another Example • Add up amounts by day, product • In SQL: SELECT date,

Another Example • Add up amounts by day, product • In SQL: SELECT date, sum(amt) FROM SALE GROUP BY date, prod. Id rollup drill-down 12

Aggregates • Operators: sum, count, max, min, median, ave • “Having” clause • Using

Aggregates • Operators: sum, count, max, min, median, ave • “Having” clause • Using dimension hierarchy – average by region (within store) – maximum by month (within date) 13

Cube Aggregation Example: computing sums. . . day 2 day 1 129 rollup drill-down

Cube Aggregation Example: computing sums. . . day 2 day 1 129 rollup drill-down 14

Cube Operators day 2 . . . day 1 sale(c 1, *, *) 129

Cube Operators day 2 . . . day 1 sale(c 1, *, *) 129 sale(c 2, p 2, *) sale(*, *, *) 15

Extended Cube * day 2 day 1 sale(*, p 2, *) 16

Extended Cube * day 2 day 1 sale(*, p 2, *) 16

Aggregation Using Hierarchies day 2 day 1 customer region country (customer c 1 in

Aggregation Using Hierarchies day 2 day 1 customer region country (customer c 1 in Region A; customers c 2, c 3 in Region B) 17

Pivoting Fact table view: Multi-dimensional cube: day 2 day 1 18

Pivoting Fact table view: Multi-dimensional cube: day 2 day 1 18