Upgrade to Pro — share decks privately, control downloads, hide ads and more …

ディメンショナル モデリング入門 / introduction-to-dimensional-modeling

ディメンショナル モデリング入門 / introduction-to-dimensional-modeling

Jumpei Chikamori

August 31, 2023
Tweet

More Decks by Jumpei Chikamori

Other Decks in Technology

Transcript

  1. Four-Step Dimensional Design Process 1. ビジネスプロセスの選択。(Select the business process) 2.

    粒度を宣言する。(Declare the Grain) 3. ディメンションを特定する。(Identify the dimensions) 4. ファクトを特定する。(Identify the facts)
  2. Four-Step Dimensional Design Process 1. ビジネスプロセスの選択。(Select the business process) 2.

    粒度を宣言する。(Declare the Grain) 3. ディメンションを特定する。(Identify the dimensions) 4. ファクトを特定する。(Identify the facts)
  3. Four-Step Dimensional Design Process 1. ビジネスプロセスの選択。(Select the business process) 2.

    粒度を宣言する。(Declare the Grain) 3. ディメンションを特定する。(Identify the dimensions) 4. ファクトを特定する。(Identify the facts)
  4. Four-Step Dimensional Design Process 1. ビジネスプロセスの選択。(Select the business process) 2.

    粒度を宣言する。(Declare the Grain) 3. ディメンションを特定する。(Identify the dimensions) 4. ファクトを特定する。(Identify the facts)
  5. Four-Step Dimensional Design Process 1. ビジネスプロセスの選択。(Select the business process) 2.

    粒度を宣言する。(Declare the Grain) 3. ディメンションを特定する。(Identify the dimensions) 4. ファクトを特定する。(Identify the facts)
  6. ファクトの特定 粒度の宣言を行っている場合、宣言した粒度通りに、 ファクトを特定するだけです。 テーブル構造的には、以下のようなイメージ。 • date_key = hoge • click_key

    = fuga • media_key = bar • click_id = hoge • media_id = 1 • clicked_at = 2022-06-12 … • click_amount = 1 • etc… クリック ファクト 宣言した粒度 「表示された広告に対するクリック1回につき、1行。」
  7. • date_key = hoge • click_key = fuga • media_key

    = bar • etc… クリック ファクト • media_key = fuga • etc… メディア ディメンション • date_key = 1 • etc… 日付ディメンション media_key date_key
  8. 先月の広告クリック数を、広告掲載メディア別で見る SELECT d_media.media_name, sum(fct_clicks.click_amount) AS click_amount FROM fct_clicks INNER JOIN

    dim_media ON fct_clicks.media_key = d_media.media_key INNER JOIN dim_date ON fct_clicks.order_date_key = d_date.date_key WHERE d_date.day_of_month = 6 GROUP BY 1
  9. さらに学びたい方へ • ディメンションモデリング ◦ https://zenn.dev/pei0804/articles/dimensional-modeling • Building a Kimball dimensional

    model with dbt ◦ https://docs.getdbt.com/blog/kimball-dimensional-model • Star Schema The Complete Reference ◦ 書籍です。