Kimball Dimensional Modeling

Data Modeling include:

  • Conceptual Modeling
  • Logical Modeling
  • Physical Modeling
  • Operational Data Modeling
  • Relational Modeling
  • Data Vault
  • Dimensional Modeling
    e.g. Kimball dimensional modeling
  • Other Modeling Approaches

Dimensional Modeling is a data modeling technique designed primarily for analytical workloads.

It organizes data around:

  • Facts — measurable business events 可以度量的业务事件
  • Dimensions — descriptive business context 描述业务上下文的信息

Kimball Dimensional Modeling

Kimball Dimensional Modeling is an approach to designing analytical data warehouses using dimensional models, centered around business processes, facts, dimensions, conformed dimensions, and a bus architecture.

Kimball Dimensional Modeling belongs to Dimmensional Modeling.

The Core Philosophy of Kimball:
Start with the business process, not the database tables.

Important concept of Kimball’s dimensional modeling

Business Process

A Business Process is a business activity that an organization performs and wants to measure, analyze, and improve.
企业正在执行的一类业务活动,而且企业希望对这类活动进行度量、分析和改进. e.g.

  • 销售 Sales
  • 订单履行 Order Fulfillment
  • 库存 Inventory
  • 支付 Payments
  • 退货 Returns
  • 保险理赔 Claims
  • 医院入院 Admissions
  • 贷款申请 Loan Applications
  • 客户服务 Customer Service

Kimball dimensional modeling starts with the business process.

Typical examples of Business Processes

Retail:

  • Sales
  • Inventory
  • Returns
  • Payments
  • Shipping

Banking:

  • Account Opening
  • Transactions
  • Payments
  • Loans
  • Credit Card Transactions
  • Fraud Detection

Government

  • Application
  • Case Processing
  • Permit Issuance
  • Payment
  • Inspection
  • Appeal

Kimball Dimensional Design — 4 Steps

The four critical steps of the Kimball lifecycle / dimensional modeling methodology are:

  1. Select the Business Process
  2. Declare the Grain
  3. Identify the Dimensions
  4. Identify the Facts

An Example: “We want to analyze credit card transactions.”

Do not create tables now.

Step 1: Select the Business Process

What is the Business Process? Credit Card Transaction

What is the Business Event? A cardholder makes a transaction
at a merchant.

Step 2: Declare the Grain

What is the Grain? One row = one credit card transaction

Step 3: Identify the Dimensions

What Dimensions?

  • Customer
  • Card
  • Merchant
  • Date
  • Time
  • Location
  • Transaction Type

Step 4: Identify the Facts

What Facts?

  • Transaction Amount
  • Fee Amount
  • Tax Amount
  • Reward Points

Finally:

                  Dim Customer
                       |
                       |
Dim Card ------- Fact Transaction ------ Dim Merchant
                       |
                       |
                    Dim Date
                       |
                       |
                    Dim Time

This is Kimball’s thought.

Implementation – Initially Physical Model

Assuming, I have decided:
Grain = one row per sales order line

#  Fact
CREATE TABLE fact_sales (
    sales_date_key       INT,
    customer_key         BIGINT,
    product_key          BIGINT,
    store_key            BIGINT,

    order_number         STRING,

    quantity             DECIMAL(18,2),
    unit_price            DECIMAL(18,2),
    discount_amount       DECIMAL(18,2),
    sales_amount          DECIMAL(18,2),
    cost_amount           DECIMAL(18,2)
);



#  Dimensions:
CREATE TABLE dim_customer (
    customer_key BIGINT,
    customer_id  STRING,
    customer_name STRING,
    province STRING,
    customer_segment STRING
);

CREATE TABLE dim_product (
    product_key BIGINT,
    product_id STRING,
    product_name STRING,
    category STRING,
    brand STRING
);

CREATE TABLE dim_date (
    date_key INT,
    calendar_date DATE,
    year INT,
    quarter INT,
    month INT,
    month_name STRING,
    day_of_week STRING
);

Grain:Fact Table

The grain defines exactly what one row in a fact table represents.
Grain 定义 Fact Table 中“一行数据到底代表什么业务事件”。

One row = one sales transaction
一行 = 一笔销售交易

One row = one sales transaction
一行 = 一笔销售交易

One row = one order line
一行 = 一个订单明细

Grain is the semantic contract of the fact table.

Three common fact grains in Kimball

In data warehousing, these three grains are formally known as:

  1. Transaction Fact grain (事务粒度)
  2. Periodic snapshot Fact grain (周期快照粒度)
  3. Accumulating snapshot Fact grain (累积快照粒度)
Fact TypeGrain核心问题
Transaction FactOne business event
一次业务事件
What happened?
发生了什么?
Periodic SnapshotOne entity/process at a periodic point
某个周期时点的状态
What was the state?
当时状态如何?
Accumulating SnapshotOne process lifecycle
一个业务流程生命周期
How did the process progress?
流程进行到哪里?

Transaction Fact Grain

One row represents one business transaction/event.

e.g. One row = one order line

DateCustomerProductStoreQtySales
Sep 13C001P001S00111200
Sep 13C001P002S0012500
Sep 13C001P003S001150

Periodic snapshot Fact grain

A row represents the state of a business process at a regular point in time.
一行代表某个业务对象/流程在一个固定周期时间点的状态。

e.g. Account Balance Snapshot
One row = Customer Account + Day

DateAccountBalance
Sep 11A00110,000
Sep 12A0019,500
Sep 13A00111,000

Accumulating snapshot Fact grain

A single row represents the entire lifecycle of a process or a specific entity that moves through multiple, predictable milestones.

e.g. Order Fulfillment

Order Created
↓
Payment Approved
↓
Warehouse Processing
↓
Shipped
↓
Delivered

We can represent the entire lifecycle of an order in one row.

OrderOrder DatePayment DateShip DateDelivery Date
10001Sep 10Sep 10Sep 11Sep 13

Grain Determines Whether a Fact Is Valid

A fact is only meaningful if it is measured at the same grain as the fact table.
一个 Fact 只有在与 Fact Table 的 Grain 相匹配时,才是有意义、可以正确分析的。

Suppose we define:

Grain: One row represents one Order Line.

That means every row in the fact table represents exactly:

One product on one order

OrderProductQuantitySales Amount
O1001iPhone1$1,200
O1001AirPods2$500
O1002MacBook1$2,000

A error fact example.

OrderProductSales AmountOrder Total
O1001iPhone1,2001,700
O1001AirPods5001,700

there is issue on the column “Order Total”
把 $1,700 放进一个 Order-Line Grain 的 Fact Table,并让它看起来像每一行的可加 Fact,是错误的设计。 我们的 Fact Grain 是 “One row represents one Order Line.” 一行一个order 的 “行” – order 上的一行。

Order Total O1001 这份order的 合计金额, 是 “Order Grain” – 一份order的. 放在目前的Fact 上就不对。

如果一定要使用 “Order Total ”, 那就再叫另外一个Fact_order,

Grain:One row per Order

OrderCustomerOrder TotalShipping Cost
O1001C001170020
O1002C002200030

Grain Determines Dimension Context

Kimball-style terminology: The grain defines not only what the fact represents, but also which dimensions can validly describe the row.

Dimensions

A Dimension is a business-oriented structure that provides the descriptive context used to analyze facts.
用于描述和分析 Fact 的业务分析结构。

A Very Important Kimball Principle

Kimball Principle: Dimensions should be understandable to business users.

Data Modeling

Data Modeling is the process of deciding how business data should be

  • structured,
  • organized,
  • related,
  • represented

so that people and computer systems can use it correctly.

In simple terms: Data Modeling = deciding what data we have, what each piece of data means, how different data is related, and how we should organize it.

Data Modeling include:

  • Conceptual Modeling
  • Logical Modeling
  • Physical Modeling
  • Operational Data Modeling
  • Relational Modeling
  • Data Vault
  • Dimensional Modeling
    e.g. Kimball dimensional modeling
  • Other Modeling Approaches

What is Data Modeling actually DOING?

We take the real business world and translate it into a structured data representation that a computer can store, query, analyze, and maintain.

Data Modeling is about MEANING, not just tables.

The basic building blocks of Data Modeling

English中文
Entity实体: 我们要管理的“东西”

可识别 + 业务相关 + 可以被描述
An Entity is a distinct business object or concept that we want to represent in data.

Identifiable + Relevant + Describable
Attribute属性: 描述这个东西的信息An Attribute describes a property or characteristic of an entity.
Relationship关系: 东西和东西之间怎么关联
Cardinality基数 / 数量关系

一个对多少个
Cardinality specifies how many instances of one Entity can be associated with an instance of another Entity.
1:1, 1:N, N:1, N:N
Key键Cardinality specifies how many instances of one Entity can be associated with an instance of another Entity.
simple, “Which exact record is this?”

A Primary Key is the chosen attribute or combination of attributes that uniquely identifies each row in a table.
A Foreign Key is an attribute in one entity/table that references the key of another entity/table.
Constraint约束

The three levels of Data Modeling

Conceptual Model

Conceptual Model is a high-level representation of the major business entities and their relationships.

Simply, what business things exist? 业务上有什么东西?

Logical Model

The Logical Data Model defines the detailed structure of the data, including entities, attributes, relationships, keys, and business rules, without depending on a specific database technology.

Simply, how should the business data be logically organized?

Physical Model

The Physical Data Model describes how the logical model will actually be implemented in a specific database, data warehouse, lakehouse, or other technology.

Simply, how will we actually store and implement the data?

ModelQuestion中文
ConceptualWhat?有什么业务东西?
LogicalHow is it organized?数据逻辑上怎么组织?
PhysicalHow is it implemented?技术上怎么真正实现?

What is Normalization?

Normalization is a data modeling technique used to organize data so that:

  • unnecessary duplication is reduced
  • data dependencies are correctly represented
  • update anomalies are minimized
  • data integrity is improved

Why do we normalize data?

Normalization organizes data around business entities and dependencies. It reduces unnecessary redundancy and prevents update, insert, and delete anomalies while improving data integrity and maintainability.
Normalization 是根据业务实体和数据依赖关系来组织数据,减少不必要的数据冗余,避免 Update、Insert 和 Delete Anomalies,同时提高数据完整性和可维护性。

First Normal Form — 1NF

A table is in 1NF when each attribute contains atomic values, meaning each cell represents a single value rather than a repeating group or list.
每个 Cell 应该保存一个 Atomic Value(原子值),而不是一个列表或重复组。

Second Normal Form — 2NF

A table is in 2NF when:

  1. It is already in 1NF 首先必须满足 1NF
  2. Every non-key attribute depends on the whole primary key, not only part of a composite key. 所有非 Key 属性必须依赖于整个 Primary Key, 不能只依赖 Composite Key 的一部分

Third Normal Form — 3NF

A table is in 3NF when:

  1. It is in 2NF
  2. Non-key attributes depend on the key, the whole key, and nothing but the key.

Grain

粒度

The grain defines exactly what one row in a fact table represents.
Grain 定义 Fact Table 中“一行数据到底代表什么业务事件”。

Key Takeaways

  1. Data Modeling translates the real business world into structured data.
    是把现实业务世界转换成结构化的数据。
  2. An Entity represents a business object or concept.
    表示一个业务对象或业务概念。
  3. An Attribute describes an Entity.
    描述 Entity 的特征
  4. A Relationship describes how Entities are connected.
    描述不同 Entity 之间如何关联。
  5. Cardinality describes how many instances of one Entity can relate to another.
    描述两个 Entity 之间“一对一、一对多、多对多”的数量关系。