Skip to main content

日付・ディメンションテーブル

概要

日付・ディメンションテーブルは、日付に関する属性を管理するテーブルです。

このテーブルは、年、月、日、曜日、祝日などの日付に関する様々な属性を提供し、時系列分析やカレンダーに基づいた集計の基盤となります。また、営業日や休日の判定にも利用され、ビジネスロジックに沿った日付の取り扱いを可能にします。

物理レイヤー

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_keyrecord_count
203012311
203012301
203012291
203012281
203012271
203012261
203012251
203012241
203012231
203012221
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_daterecord_count
2030-12-311
2030-12-301
2030-12-291
2030-12-281
2030-12-271
2030-12-261
2030-12-251
2030-12-241
2030-12-231
2030-12-221
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_monthrecord_count
20301231
20301031
20300831
20300731
20300531
20300331
20300131
20291231
20291031
20290831
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
yearrecord_count
2028366
2024366
2020366
2016366
2012366
2008366
2004366
2000366
1996366
1992366
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
monthrecord_count
124061
114061
104061
94061
84061
74061
64061
54061
44061
34061
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
dayrecord_count
281572
271572
261572
251572
241572
231572
221572
211572
201572
191572
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_weekrecord_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_numberrecord_count
015033
181572
171572
161572
151572
141572
131572
121572
111572
101572
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_holidayrecord_count
NON_HOLIDAY32814
休日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_holidayrecord_count
NON_PUBLIC_HOLIDAY46280
祝日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_namerecord_count
NON_PUBLIC_HOLIDAY46280
憲法記念日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_dayrecord_count
-454381
-452601
-451671
-453761
-456761
-456891
-455051
-453961
-454461
-455721

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
  • 説明: 一文字のスナップショット曜日。

メジャー属性

なし

メトリクス

なし

ER 図