SEM 6 › Data Mining › Week 06
Data Mining · Week 06

Schemas for the Multidimensional Model

Star, snowflake and fact constellation schemas, data warehouse vs data mart, defining cubes with DMQL, and concept hierarchies.

ITE34321 video · 11 min📄 week 6.pdf

▶Lecture videos

Click any timestamp — here or inside the notes — to jump the video to that moment. Your position is remembered.

1Why a different schema for warehouses?

  • Relational databases (OLTP) are designed with the entity-relationship (ER) model: a set of entities and the relationships between them.
  • A data warehouse needs a concise, subject-oriented schema that supports on-line data analysis.
  • The most popular model for a warehouse is the multidimensional model. It comes in three forms:
Star schemaSnowflake schemaFact constellation

In all three there is a fact table (holds the measures plus keys to the dimensions) and dimension tables (describe each dimension).

2Star schema

A central fact table connected to one table per dimension. It is the simplest schema.

  • Example (Figure 6-1): the sales fact table has keys to time, item, branch, location and two measures, dollars_sold and units_sold.
  • Each dimension is exactly one table.
Its drawback: redundancy

The location table holds (location_key, street, city, province_or_state, country). Vancouver and Victoria are both in British Columbia, Canada, so "British Columbia, Canada" is repeated in many rows:

(…, Vancouver, British Columbia, Canada) (…, Victoria, British Columbia, Canada)

3Snowflake schema

A star schema whose dimension tables are normalised (split into extra tables). The diagram branches out like a snowflake.

  • Example (Figure 6-2):
  • item → item(item_key, item_name, brand, type, supplier_key) + supplier(supplier_key, supplier_type)
  • location → location(location_key, street, city_key) + city(city_key, city, province_or_state, country)

Advantages

  • Reduces redundancy (normalised)
  • Easy to maintain
  • Saves storage space

Disadvantages

  • The space saved is negligible compared with the size of the fact table
  • More joins are needed per query, so browsing is less effective (slower)
Which is more popular?

The star schema is more popular than the snowflake, because query speed matters more than the small storage saving.

4Fact constellation (galaxy schema)

Multiple fact tables that share dimension tables. It is a collection of stars, hence also called a galaxy schema.

Example (Figure 6-3): two fact tables.

Fact table Keys (dimensions) Measures
sales time, item, branch, location dollars_sold, units_sold
shipping item, time, shipper, from_location, to_location dollars_cost, units_shipped

time, item and location are shared between both fact tables.

🧪 Try it — Schema viewer

Exam focus

"Compare star, snowflake and fact constellation schemas" with diagrams is a favourite question. Draw the sales example for each. For snowflake show item → supplier and location → city. For constellation show sales + shipping sharing time/item/location.

5Data warehouse vs data mart

Data warehouse Data mart
Scope Enterprise-wide: subjects across the whole organisation (customers, items, sales, assets, personnel) Department-wide: a departmental subset of the warehouse
Subjects Multiple, interrelated Selected / single subjects
Schema commonly used Fact constellation (models multiple interrelated subjects) Star or snowflake (single subject); star is more popular and efficient
Data sources Many Few
Size Large (100 GB – TB+) Smaller
Build time Months to years Weeks to months
Picture it

The warehouse is the central store of a supermarket chain. A data mart is the marketing department's shelf holding just the subjects it needs.

6Defining cubes with DMQL

A Data Mining Query Language (DMQL) specifies mining tasks the way SQL specifies relational queries. Warehouses and marts are defined with two primitives:

define cube <cube_name> [<dimension_list>]: <measure_list>
define dimension <dimension_name> as (<attribute_or_subdimension_list>)

Star schema in DMQL

define cube sales_star [time, item, branch, location]:
    dollars_sold = sum(sales_in_dollars), avg_sales = avg(sales_in_dollars),
    units_sold = count(*)
define dimension time     as (time_key, day, day_of_week, month, quarter, year)
define dimension item     as (item_key, item_name, brand, type, supplier_type)
define dimension branch   as (branch_key, branch_name, branch_type)
define dimension location as (location_key, street, city, province_or_state, country)

define cube creates the central fact table (4 dimensions plus the measures). Each define dimension creates one dimension table.

Snowflake schema in DMQL

The only change is that sub-dimensions are nested inside the parent dimension:

define dimension item as (item_key, item_name, brand, type,
                          supplier(supplier_key, supplier_type))
define dimension location as (location_key, street,
                          city(city_key, province_or_state, country))

Defining supplier inside item implicitly creates a supplier_key in the item table. city inside location implicitly creates a city_key.

Fact constellation in DMQL

Define the sales cube as in the star schema, then define shipping and reuse the shared dimensions:

define cube shipping [time, item, shipper, from_location, to_location]:
    dollar_cost = sum(cost_in_dollars), unit_shipped = count(*)
define dimension time  as time in cube sales
define dimension item  as item in cube sales
define dimension shipper as (shipper_key, shipper_name,
                             location as location in cube sales, shipper_type)
define dimension from_location as location in cube sales
define dimension to_location   as location in cube sales

"as … in cube sales" is how a dimension is shared between fact tables.

Spot the difference fast
  • Star: flat attribute lists
  • Snowflake: nested brackets, supplier(…) and city(…)
  • Constellation: two define cube statements plus … in cube sales

7Concept hierarchies

A concept hierarchy is a sequence of mappings from low-level concepts to higher-level, more general concepts.

Location hierarchy (Figure 6-4)
                        all
              ┌──────────┴──────────┐
           Canada                  USA
       ┌──────┴──────┐        ┌─────┴──────┐
 British Columbia  Ontario  New York    Illinois
       │              │        │            │
   Vancouver      Toronto   New York     Chicago

city → province_or_state → country → all

  • Many hierarchies are implicit in the schema. If location has attributes number, street, city, province_or_state, zip_code and country, a total order gives: street < city < province_or_state < country (Figure 6-5).
  • Roll-up climbs the hierarchy (city → country). Drill-down goes back down.

8Weka 1.2 — Exploring the Explorer

The Weka video walks through the Explorer, the main interface you'll use:

  • Preprocess tab: open a dataset (ARFF file), see the list of attributes, the number of instances, and per-attribute statistics and a histogram. Filters are also applied here.
  • Other tabs: Classify, Cluster, Associate, Select attributes, Visualize.
  • Datasets have instances (rows) and attributes (columns). One attribute is usually the class.

9Quick revision sheet

Concept Remember it as
ER model For OLTP; warehouses need subject-oriented multidimensional schemas
Star 1 fact table + 1 table per dimension; simplest; some redundancy
Snowflake Normalised dimensions (item→supplier, location→city); less redundancy, more joins
Fact constellation Multiple fact tables sharing dimensions (sales + shipping); a.k.a. galaxy
Warehouse Enterprise-wide, many subjects, uses fact constellation
Data mart Department subset, selected subjects, uses star (preferred) or snowflake
DMQL primitives define cube name [dims]: measures · define dimension name as (attrs)
Snowflake in DMQL Nested sub-dimension creates key implicitly
Sharing in DMQL define dimension time as time in cube sales
Concept hierarchy Low → high level mappings; street < city < province/state < country

?Self-check quiz

10 questions on this week. Answer them all, then press Check my answers. Your best and latest scores are saved and shown on the subject page.