Introductions to Dimensions

Objectives:

  • learn about dimensions and their implementation in relational database
  • how to model concept hierarchies of a dimension
  • conforming dimension labels
  • simple dimension loading with mapping

Keywords and concepts:

  • dimension table
  • key
  • mapping and mapping table
  • concept hierarchy
  • date dimension table

Preparation


In [ ]:
# Required relevant imports

import sqlalchemy as sa
import csv

In [ ]:
# Playground imports – not important to the topic

# Ipython notebook prettyness
from IPython.display import HTML
from tabulate import tabulate


def pretty_table(data, headers):
    """Print nice tables in the ipython notebook"""
    return HTML(tabulate(data, headers, "html"))

Load a Dimension

To warm up, we will load a dimension table from a CSV file. The CSV file contains columns: id, customer_name, customer_type.


In [ ]:
with open("03-dimensions/customer.csv") as f:
    ...

In [ ]: