Dimensional modeling is a design technique used to build data warehouses that make analytical queries fast and intuitive. In an interview you need to convey three things quickly: the definition, the core mechanism, and why you would choose it over other models.
One‑Sentence Definition
A dimensional model structures business events as facts linked to descriptive dimensions, arranged in a star‑ or snowflake‑shaped schema to support ad‑hoc analysis.
Core Mechanism
Facts and Measures
Facts are the numeric values you want to aggregate—sales amount, units shipped, or call duration. Each fact row contains foreign keys that point to dimension tables.
Dimensions
Dimensions describe the context of a fact: time, product, customer, or geography. They store attributes that are typically low‑cardinality (e.g., month, product category) and are denormalized for readability.
Star vs. Snowflake
- Star schema: Dimension tables are flat (one level of hierarchy). Simpler queries, faster joins, but some redundancy.
- Snowflake schema: Dimensions are normalized into multiple related tables. Saves space and enforces consistency, at the cost of extra joins.
Trade‑offs
| Aspect | Star Schema | Snowflake Schema |
|---|---|---|
| Query simplicity | Very simple, fewer joins | More joins, slightly more complex |
| Storage | Redundant attribute values | Less redundancy, smaller footprint |
| Maintenance | Easier to understand, quicker onboarding | More disciplined, harder for new analysts |
| Performance | Typically faster for OLAP queries | May be slower due to join overhead |
In practice you pick the shape that matches the team's priorities. If analysts need to write queries on the fly, a star schema is often preferred. If storage costs are a concern or you have deep hierarchies, a snowflake may be justified.
Concrete Example
Imagine a retail company tracking daily sales.
-- Fact table
CREATE TABLE fact_sales (
sales_id BIGINT PRIMARY KEY,
product_key INT,
store_key INT,
date_key INT,
units_sold INT,
revenue DECIMAL(12,2)
);
-- Dimension tables (star style)
CREATE TABLE dim_product (
product_key INT PRIMARY KEY,
sku VARCHAR(20),
name VARCHAR(100),
category VARCHAR(50),
brand VARCHAR(50)
);
CREATE TABLE dim_store (
store_key INT PRIMARY KEY,
store_name VARCHAR(100),
city VARCHAR(50),
region VARCHAR(50),
country VARCHAR(50)
);
CREATE TABLE dim_date (
date_key INT PRIMARY KEY,
date DATE,
day_of_week VARCHAR(10),
month VARCHAR(10),
quarter VARCHAR(10),
year INT
);
A typical query to see monthly revenue by product category would join the fact table to dim_product and dim_date, then group by category and year/month. Because the dimensions are flat, the query planner can use simple hash joins, delivering results in seconds even on multi‑gigabyte datasets.
Typical Interview Questions
- What is a dimensional model and why is it useful? – Answer with the one‑sentence definition, then note that it aligns with how business users think about data.
- Explain the difference between a star and a snowflake schema. – Highlight join count, storage, and maintenance trade‑offs.
- How do you decide which attributes belong in a dimension versus the fact table? – Talk about grain, volatility, and whether the attribute is used for filtering/grouping.
- What are slowly changing dimensions and how do you handle them? – Briefly describe Type 1 (overwrite) and Type 2 (historical rows) strategies.
- Can you walk me through a dimensional model you built? – Use a real project (e.g., the retail example) and mention the business outcome.
When answering, keep the story grounded in your own experience. If you have a resume entry about building a data warehouse, reference it: “In my last role I designed a star schema for a sales data mart that reduced query latency by roughly half.” Tools like Call Assistant can help you rehearse this answer aloud and keep follow‑up questions on track.
60‑Second Spoken Version
“Dimensional modeling is a way to arrange data for analytics by separating measurable events—facts—from descriptive attributes—dimensions. The fact table holds numbers like revenue and foreign keys to dimension tables such as product, store, and date. In a star schema each dimension is flat, which makes queries simple and fast; a snowflake schema normalizes dimensions, saving space but adding joins. The main trade‑off is between ease of use and storage efficiency. In a recent project I built a star schema for daily sales, linking a fact table to product, store, and date dimensions. This let analysts slice revenue by month, region, or product category with just a few joins, and we saw query times drop dramatically. If you need historical tracking of attributes like product category changes, you’d use a Type 2 slowly changing dimension.”
How to Practice This
- Write a one‑sentence definition and record yourself saying it. Play it back to ensure clarity.
- Build a tiny star schema in a local database (e.g., SQLite). Populate it with sample data and write a few aggregation queries.
- Simulate an interview: have a colleague ask the five typical questions. Use Call Assistant to capture your answers and get instant feedback on pacing and relevance.
FAQ
- What is the “grain” of a fact table? The grain defines the most detailed level of data stored—e.g., one row per transaction, per day, or per month. All dimensions must align to that grain.
- When would you choose a snowflake over a star schema? When you have deep hierarchical dimensions (like geography with country > state > city) and need to enforce referential integrity or reduce storage.
- How do slowly changing dimensions affect query performance? Type 2 dimensions add rows for each change, which can increase join size but preserve history. Proper indexing mitigates the impact.
- Can dimensional modeling be used for real‑time analytics? It’s primarily for batch‑oriented data warehouses, but modern platforms allow near‑real‑time feeds into dimensional tables, especially when combined with incremental loading.
Frequently asked questions
What is the “grain” of a fact table?
The grain defines the most detailed level of data stored—e.g., one row per transaction, per day, or per month. All dimensions must align to that grain.
When would you choose a snowflake over a star schema?
When you have deep hierarchical dimensions (like geography with country > state > city) and need to enforce referential integrity or reduce storage.
How do slowly changing dimensions affect query performance?
Type 2 dimensions add rows for each change, which can increase join size but preserve history. Proper indexing mitigates the impact.
Can dimensional modeling be used for real‑time analytics?
It’s primarily for batch‑oriented data warehouses, but modern platforms allow near‑real‑time feeds into dimensional tables, especially when combined with incremental loading.
#concept#dimensional modeling#data warehouse#interview prep#analytics