日付・ディメンションテーブル
概要
日付・ディメンションテーブルは、日付に関する属性を管理するテーブルです。
このテーブルは、年、月、日、曜日、祝日などの日付に関する様々な属性を提供し、時系列分析やカレンダーに基づいた集計の基盤となります。また、営業日や休日の判定にも利用され、ビジネスロジックに沿った日付の取り扱いを可能にします。
物理レイヤー
1. dim_date
基本情報
dim_date:
description: "日付・ディメンションテーブル"
location: "BigQuery"
full_name: "enterprise-dw-376005.mart.dim_date"
surrogate_key: "date_key"
primary_keys: ["full_date"]
カラム
1. date_key
- 日本語名: 日付キー
- データ型:
string - 説明:
full_dateのサロゲートキー(スマートキー)。結合キーとして使用する。
度数分布表
select
date_key,
count(*) as record_count
from `enterprise-dw-376005.mart.dim_date`
group by 1
order by 2 desc
limit 10
| date_key | record_count |
|---|---|
| 20301231 | 1 |
| 20301230 | 1 |
| 20301229 | 1 |
| 20301228 | 1 |
| 20301227 | 1 |
| 20301226 | 1 |
| 20301225 | 1 |
| 20301224 | 1 |
| 20301223 | 1 |
| 20301222 | 1 |
2. full_date
- 日本語名: 日付
- データ型:
date - 説明:
yyyy-mm-dd表記の日付。
度数分布表
select
full_date,
count(*) as record_count
from `enterprise-dw-376005.mart.dim_date`
group by 1
order by 2 desc
limit 10
| full_date | record_count |
|---|---|
| 2030-12-31 | 1 |
| 2030-12-30 | 1 |
| 2030-12-29 | 1 |
| 2030-12-28 | 1 |
| 2030-12-27 | 1 |
| 2030-12-26 | 1 |
| 2030-12-25 | 1 |
| 2030-12-24 | 1 |
| 2030-12-23 | 1 |
| 2030-12-22 | 1 |
3. year_and_month
- 日本語名: 年月
- データ型:
int64 - 説明:
yyyy-mm表記の年月。
度数分布表
select
year_and_month,
count(*) as record_count
from `enterprise-dw-376005.mart.dim_date`
group by 1
order by 2 desc
limit 10
| year_and_month | record_count |
|---|---|
| 203012 | 31 |
| 203010 | 31 |
| 203008 | 31 |
| 203007 | 31 |
| 203005 | 31 |
| 203003 | 31 |
| 203001 | 31 |
| 202912 | 31 |
| 202910 | 31 |
| 202908 | 31 |
4. year
- 日本語名: 年
- データ型:
int64 - 説明:
yyyy表記の年。
度数分布表
select
year,
count(*) as record_count
from `enterprise-dw-376005.mart.dim_date`
group by 1
order by 2 desc
limit 10
| year | record_count |
|---|---|
| 2028 | 366 |
| 2024 | 366 |
| 2020 | 366 |
| 2016 | 366 |
| 2012 | 366 |
| 2008 | 366 |
| 2004 | 366 |
| 2000 | 366 |
| 1996 | 366 |
| 1992 | 366 |
5. month
- 日本語名: 月
- データ型:
int64 - 説明:
m表記の月。
度数分布表
select
month,
count(*) as record_count
from `enterprise-dw-376005.mart.dim_date`
group by 1
order by 2 desc
limit 10
| month | record_count |
|---|---|
| 12 | 4061 |
| 11 | 4061 |
| 10 | 4061 |
| 9 | 4061 |
| 8 | 4061 |
| 7 | 4061 |
| 6 | 4061 |
| 5 | 4061 |
| 4 | 4061 |
| 3 | 4061 |
6. day
- 日本語名: 日
- データ型:
int64 - 説明:
d表記の日。
度数分布表
select
day,
count(*) as record_count
from `enterprise-dw-376005.mart.dim_date`
group by 1
order by 2 desc
limit 10
| day | record_count |
|---|---|
| 28 | 1572 |
| 27 | 1572 |
| 26 | 1572 |
| 25 | 1572 |
| 24 | 1572 |
| 23 | 1572 |
| 22 | 1572 |
| 21 | 1572 |
| 20 | 1572 |
| 19 | 1572 |
7. day_of_week
- 日本語名: 曜日
- データ型:
string - 説明: 一文字の曜日。
度数分布表
select
day_of_week,
count(*) as record_count
from `enterprise-dw-376005.mart.dim_date`
group by 1
order by 2 desc
limit 10
| day_of_week | record_count |
|---|---|
| 火 | 6836 |
| 月 | 6836 |
| 金 | 6835 |
| 水 | 6835 |
| 木 | 6835 |
| 日 | 6835 |
| 土 | 6835 |
8. business_day_number
- 日本語名: 営業日番号
- データ型:
int64 - 説明: 当月の営業日番号。欠損値は
0として扱う。
度数分布表
select
business_day_number,
count(*) as record_count
from `enterprise-dw-376005.mart.dim_date`
group by 1
order by 2 desc
limit 10
| business_day_number | record_count |
|---|---|
| 0 | 15033 |
| 18 | 1572 |
| 17 | 1572 |
| 16 | 1572 |
| 15 | 1572 |
| 14 | 1572 |
| 13 | 1572 |
| 12 | 1572 |
| 11 | 1572 |
| 10 | 1572 |
9. is_holiday
- 日本語名: 休日フラグ
- データ型:
string - 説明: 休日フラグ。土日祝を休日として扱う。
度数分布表
select
is_holiday,
count(*) as record_count
from `enterprise-dw-376005.mart.dim_date`
group by 1
order by 2 desc
limit 10
| is_holiday | record_count |
|---|---|
| NON_HOLIDAY | 32814 |
| 休日 | 15033 |
10. is_public_holiday
- 日本語名: 祝日フラグ
- データ型:
string - 説明: 祝日フラグ。
度数分布表
select
is_public_holiday,
count(*) as record_count
from `enterprise-dw-376005.mart.dim_date`
group by 1
order by 2 desc
limit 10
| is_public_holiday | record_count |
|---|---|
| NON_PUBLIC_HOLIDAY | 46280 |
| 祝日 | 1567 |
11. public_holiday_name
- 日本語名: 祝日の名前
- データ型:
string - 説明: 祝日の名前。
度数分布表
select
public_holiday_name,
count(*) as record_count
from `enterprise-dw-376005.mart.dim_date`
group by 1
order by 2 desc
limit 10
| public_holiday_name | record_count |
|---|---|
| NON_PUBLIC_HOLIDAY | 46280 |
| 憲法記念日 | 131 |
| 秋分の日 | 131 |
| 春分の日 | 131 |
| 元日 | 131 |
| こどもの日 | 131 |
| 成人の日 | 131 |
| 文化の日 | 131 |
| 勤労感謝の日 | 131 |
| 休日 | 122 |
12. relative_day
- 日本語名: 相対日数
- データ型:
int64 - 説明: 今日との相対日数。過去はマイナス、未来はプラス。
度数分布表
select
relative_day,
count(*) as record_count
from `enterprise-dw-376005.mart.dim_date`
group by 1
order by 2 desc
limit 10
| relative_day | record_count |
|---|---|
| -45438 | 1 |
| -45260 | 1 |
| -45167 | 1 |
| -45376 | 1 |
| -45676 | 1 |
| -45689 | 1 |
| -45505 | 1 |
| -45396 | 1 |
| -45446 | 1 |
| -45572 | 1 |
ER 図
🚧 サンプル SQL
論理レイヤー
1. order_date_dimension
基本情報
order_date_dimension:
description: "注文日・ロールプレイング・ディメンションテーブル"
location: "dbt Semantic Layer"
primary_key: "order_date_key"
foreign_keys: null
agg_time_dimension: null
ディメンショナル属性
1. order_year_and_month
- 日本語名: 注文年月
- データ型:
categorical - 説明:
yyyy-mm表記の注文年月。
2. order_year
- 日本語名: 注文年
- データ型:
categorical - 説明:
yyyy表記の注文年。
3. order_month
- 日本語名: 注文月
- データ型:
categorical - 説明:
m表記の注文月。
4. order_day
- 日本語名: 注文日
- データ型:
categorical - 説明:
d表記の注文日。
5. order_day_of_week
- 日本語名: 注文曜日
- データ型:
categorical - 説明: 一文字の注文曜日、月曜日を
1、日曜日を7とし、「[1-7]. a」の形式に変換。
6. is_holiday
- 日本語名: 休日フラグ
- データ型:
categorical - 説明: 土日祝を休日として扱う。
7. is_public_holiday
- 日本語名: 祝日フラグ
- データ型:
categorical - 説明: 祝日フラグ。
メジャー属性
なし
メトリクス
なし
ER 図
2. first_order_date_dimension
基本情報
first_order_date_dimension:
description: "初回注文日・ロールプレイング・ディメンションテーブル"
location: "dbt Semantic Layer"
primary_key: "first_order_date_key"
foreign_keys: null
agg_time_dimension: null
ディメンショナル属性
1. first_order_year_and_month
- 日本語名: 初回注文年月
- データ型:
categorical - 説明:
yyyy-mm表記の初回注文年月。
2. first_order_year
- 日本語名: 初回注文年
- データ型:
categorical - 説明:
yyyy表記の初回注文年。
メジャー属性
なし
メトリクス
なし
ER 図
3. snapshot_date_dimension
基本情報
snapshot_date_dimension:
description: "スナップショット日・ロールプレイング・ディメンションテーブル"
location: "dbt Semantic Layer"
primary_key: "snapshot_date_key"
foreign_keys: null
agg_time_dimension: null
ディメンショナル属性
1. snapshot_year_and_month
- 日本語名: スナップショット年月
- データ型:
categorical - 説明:
yyyy-mm表記のスナップショット年月。
2. snapshot_year
- 日本語名: スナップショット年
- データ型:
categorical - 説明:
yyyy表記のスナップショット年。
3. snapshot_month
- 日本語名: スナップショット月
- データ型:
categorical - 説明:
m表記のスナップショット月。
4. snapshot_day
- 日本語名: スナップショット日
- データ型:
categorical - 説明:
d表記のスナップショット日。
5. snapshot_day_of_week
- 日本語名: スナップショット曜日
- データ型:
categorical - 説明: 一文字のスナップショット曜日。
メジャー属性
なし
メトリクス
なし