# Dimensional Modeling

> Organizes data into fact tables (metrics) and dimension tables (descriptive attributes) for intuitive querying.

- **Category**: Data Science
- **Subcategory**: Data Warehouse
- **Canonical URL**: https://designpattern.fyi/patterns/dimensional-modeling/

---

## Description
**Context**: Dimensional modeling, popularized by Ralph Kimball, structures data warehouses for intuitive querying and performance. Facts are numeric measurements, dimensions provide context.


## Use Cases
Data warehouses, business intelligence tools, and analytics platforms where business users need intuitive data access.



## Implementation Example

```python
# Dimensional Modeling Pattern # Fact table: sales transactions fact_sales = { "sale_id": 1, "date_key": 20260101, "customer_key": 101, "product_key": 201, "revenue": 100.00, "quantity": 2 }
# Dimension table: customer attributes dim_customer = { "customer_key": 101, "name": "Alice", "segment": "Premium", "region": "West" }
# Query: Revenue by customer segment # JOIN fact_sales with dim_customer on customer_key # GROUP BY dim_customer.segment, SUM(fact_sales.revenue)
```



## Trade-offs


### Advantages

- - Intuitive for business users

- - Query performance

- - BI tool compatibility

- - Standardized approach




### Considerations & Drawbacks

- - Schema rigidity

- - Redundancy storage

- - ETL complexity

- - Not suitable for all use cases







