Dimension Tables: The 'Who, What, Where, When' of Your Data

Dimension tables provide the descriptive context—the 'who, what, where, when'—for raw numbers in a fact table. They are the backbone of data warehouses, letting you slice sales data by product or region. The footgun is polluting them with transactional data.
Why it exists
Raw data, like a list of sales transactions, is just numbers. To make sense of it, you need context. Was that sale for a laptop or a mouse? To a customer in New York or London? On a weekday or a weekend? Answering these questions requires joining raw facts with descriptive attributes. Dimension tables were created to store this descriptive context efficiently for analysis.
The mental model
Think of a fact table as a spreadsheet of numbers (e.g., sales amount, quantity sold) and a dimension table as the labels for the rows and columns. The fact table tells you what happened in numerical terms, while the dimension tables tell you the who, what, where, and when behind those numbers. For example, a fact_sales table has a product_key, but the dim_product table tells you that product_key 123 is a "Red T-Shirt, Size L".
How it works
A dimension table has a single primary key (the dimension key) that is referenced by a foreign key in a central fact table. Each row represents a unique person, product, place, or time. The columns are descriptive attributes, like product_name, category, color, or brand. These tables are usually wide and denormalized, meaning they contain redundant information to avoid complex joins during analysis. For instance, a dim_store table might include city, state, and country in every row.
When to use it
Use dimension tables when building a data warehouse or data mart for business intelligence and analytical reporting (OLAP). They are essential for creating star or snowflake schemas. They are perfect for situations where you need to "slice and dice" data, such as viewing sales by region, analyzing website traffic by marketing campaign, or tracking employee performance by department.
When not to use it
Avoid this structure for Online Transaction Processing (OLTP) systems, like an e-commerce checkout system. These systems prioritize fast writes and data integrity through normalization (e.g., 3rd Normal Form). A wide, denormalized dimension table would be inefficient and difficult to maintain in a high-throughput transactional environment.
One canonical example
A retail company has a fact_sales table with columns like date_key, product_key, store_key, and sales_amount. To understand these sales, they use dimension tables. The dim_product table, linked by product_key, contains columns like product_name and category. The dim_store table, linked by store_key, has store_name and city. An analyst can then join these tables to ask: "What were the total sales for the 'Electronics' category in the 'New York' city last quarter?"
Interview question
What is the primary function of a dimension table in a data warehousing environment?
- a.To store high-volume, real-time transactional records for operational systems.
- b.To provide descriptive attributes that give context to numerical facts for analytical reporting.Correct
- c.To pre-calculate and store aggregated metrics to speed up dashboard loading times.
- d.To ensure data integrity and reduce redundancy through strict normalization across all tables.
Why? this is the answer
The card states dimension tables provide "descriptive context—the 'who, what, where, when'—for raw numbers in a fact table" and are used for "analytical reporting." Option A describes a function of OLTP systems, which the card explicitly advises against using dimension tables for.
Just read this? Test yourself on what you have been reading.
Read the original → en.wikipedia.org
- #data warehousing
- #databases
- #star schema
- #olap
- #architecture
Put your scrolling time to good use
Learn one idea, try a quiz and save useful cards for revision. Tezvyn makes it easy to learn and stay current in your tech field, a few minutes at a time.
The iPhone app is on the way
We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.
Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.
We are hiring for this. Every open role lists the topics its interview covers, so you can prepare for the real thing rather than guessing.
See open roles