MSDN Documentation
Dimensional Modeling

Dimensional Modeling in Data Warehousing

Dimensional modeling is a data modeling technique used in data warehousing that is optimized for querying and analysis. Unlike normalized data models used in transactional systems (OLTP), dimensional models are designed for fast data retrieval and business intelligence (BI) reporting. It is typically comprised of fact tables and dimension tables.

Core Concepts

The foundation of dimensional modeling rests on two fundamental types of tables:

Fact Tables

Fact tables are at the center of a dimensional model. They contain the quantitative, measurable data points (measures) that represent business events or transactions. Each row in a fact table represents a specific event, such as a sale, a website click, or a manufacturing step.

Dimension Tables

Dimension tables surround the fact table and provide descriptive context for the measures. They contain attributes that are used to filter, group, and label the data in the fact table. Each dimension table represents a business concept (e.g., Product, Customer, Date, Store).

Dimensional Model Structures

Dimensional models are typically visualized using schemas like the Star Schema and Snowflake Schema.

Star Schema

The star schema is the simplest and most common type of dimensional model. It features a central fact table connected to several denormalized dimension tables, resembling a star shape. This structure is optimized for performance due to fewer joins.

Example: Sales Data


    -- Fact Table: FactSales
    CREATE TABLE FactSales (
        DateKey INT,
        ProductKey INT,
        CustomerKey INT,
        StoreKey INT,
        SalesAmount DECIMAL(10, 2),
        Quantity INT,
        FOREIGN KEY (DateKey) REFERENCES DimDate(DateKey),
        FOREIGN KEY (ProductKey) REFERENCES DimProduct(ProductKey),
        FOREIGN KEY (CustomerKey) REFERENCES DimCustomer(CustomerKey),
        FOREIGN KEY (StoreKey) REFERENCES DimStore(StoreKey)
    );

    -- Dimension Table: DimProduct
    CREATE TABLE DimProduct (
        ProductKey INT PRIMARY KEY,
        ProductName VARCHAR(255),
        Category VARCHAR(100),
        Brand VARCHAR(100),
        -- ... other product attributes
    );
                

Snowflake Schema

The snowflake schema is an extension of the star schema where dimension tables are normalized into multiple related tables. This reduces data redundancy but can increase query complexity due to more joins.

Benefits of Dimensional Modeling

When to Use Dimensional Modeling

Dimensional modeling is best suited for data warehousing and data mart environments where the primary goal is analytical reporting, business intelligence, and decision support. It is less suitable for transactional systems that require frequent updates and complex data integrity constraints.

Note: Choosing the right granularity for fact tables is crucial for effective analysis. It should align with the business questions you intend to answer.
Tip: Denormalizing dimension tables in a star schema generally leads to better query performance, though it may introduce some redundancy.