Data modeling interview questions you can run.
A data modeling interview asks what one row of a table is, which numbers can be added up, and how history is kept. The surest way to answer is to prove it on data. Each of these 8 questions gives you linked tables and asks for the query that settles a modeling decision. It runs in your browser, and your result is checked.
Free · No signup to run or check
Four ideas behind most modeling questions.
- Grain
- What one row of a table stands for, and the count that proves it. A generated ID is unique in any table, so its uniqueness proves nothing.
- Joins that repeat rows
- What happens to a total when two tables that each hold several rows per order are joined to each other, and how to show the size of the error.
- What can be added up
- Revenue adds across everything. A balance adds across products but not across dates. A percentage has to be rebuilt from its parts.
- History
- How to answer a question about a past date: a row per period, a row per order with its milestones, or a join to the version in effect at the time.
8 questions, from stating a grain to joining as of a date.
Each entry shows the question as you would hear it, the idea it tests, and the mistake that most often fails it. Try the question before you read the mistake.
What is one row of inventory_movements?
A teammate plans to build a daily stock table by joining inventory_movements to a calendar, on the assumption that it holds one row per product, warehouse, and day. Before the join is written, you are asked to check that grain: what one row of the table stands for.
- What it tests
- Stating the grain of a table and testing it by counting the rows each assumed key has
- The mistake that fails it
- Checking that movement_id is unique, which is true of any generated ID and says nothing about what one row means
Margin percent by category
A product manager works out a margin percent for every order line and averages those percentages to get one figure per category. Finance divides total margin by total revenue and gets a different number for every category.
- What it tests
- Recognizing a non-additive measure and rebuilding it from its additive parts
- The mistake that fails it
- Averaging the margin percent of each order line, which lets a small line count as much as a large one
Revenue by payment method, counted once
A report of item revenue by payment method adds up to more than the whole of order_items. It joins order_items to payments on order_id, and an order can have several rows in each of those tables.
- What it tests
- Seeing that two child tables of the same parent cannot be joined to each other row for row
- The mistake that fails it
- Joining order_items to payments on order_id, which repeats an order's items for every payment attempt
Inventory on hand for the quarter
A quarterly dashboard reports 362,223 units of components on hand for the fourth quarter of 2025, about three times what the warehouses hold. It was built by adding up month-end stock.
- What it tests
- Treating a balance as semi-additive: add it across products and warehouses, never across dates
- The mistake that fails it
- Adding the three month-end balances into one quarter figure, which counts the same stock three times
One row per order, from placed to refunded
Operations wants to follow each order through its life: placed, paid, and refunded if that happened. The three moments are stored in three tables, and a payment can take more than one attempt.
- What it tests
- Building an accumulating snapshot: one row per order, a column per milestone, and the lag between them
- The mistake that fails it
- Inner joining the milestone tables, which keeps only the orders that reached every milestone
Spend and purchases by channel, side by side
Marketing wants 2025 spend and 2025 purchases in one table by channel. Spend is recorded per campaign per day and purchases are recorded per conversion, so the two tables do not have the same grain.
- What it tests
- Drilling across two fact tables: summarize each at the shared dimension, then join the summaries
- The mistake that fails it
- Inner joining the two summaries, which drops every channel that is missing from either one
Headcount at each quarter end
HR wants a headcount table for 2024 and 2025 with one row per quarter end. There is no history table to read it from: each employment record has a start date, an end date if the person has left, and the status as it is today.
- What it tests
- Building a periodic snapshot from start and end dates, with one row per period
- The mistake that fails it
- Filtering on today's employment_status, which removes people who were employed at the time and have since left
Which model was the default when the session ran?
Finance wants session counts by the default model each agent was running when the session took place. The default model is set on the agent version, and agents have been moved between models during the year. The interviewer adds a condition: find the version from the release dates, then show that it agrees with the version key stored on the session.
- What it tests
- A point-in-time join to a versioned table, on a date range that includes its start and excludes its end
- The mistake that fails it
- Comparing against retired_at without allowing for the current version, where it is empty, so every session on a live version drops out
Answer out loud first, then prove it.
- 01
State the grain
Before you write anything, say what one row of each table is and what one row of your result will be.
- 02
Predict the wrong answer
Most of these questions have a tempting query that runs and returns the wrong number. Say what it is and why it is wrong before you avoid it.
- 03
Name the table you would build
Once your result is checked, say which table would save the next person from writing this query: a periodic snapshot, an accumulating snapshot, or a fact table at a finer grain.
The rest of the interview loop.
- SQL screenSQL interview questions you can run
Ten graded questions on joins, window functions, and getting a definition right.
- Mock interviewAnalytics engineer mock interview
Eight graded tasks from the daily work: a data test, a deduplication, an incremental load, a reconciliation.
- RefresherFact tables and dimension tables
The difference between the two, with examples. Read it if the grain and additivity questions were hard.
- RefresherSlowly changing dimensions
How a dimension keeps history, with the SQL for Type 2. It is the background for the question on joining as of a date.
- VocabularyThe modeling glossary
Short definitions with a SQL example each: periodic and accumulating snapshots, additive facts, conformed dimensions.
- Interview kitThe analytics engineering interview kit
The four rounds of the loop, with worked SQL and modeling answers and a seven-day drill plan.
About this question set
- What is asked in a data modeling interview?
- Most questions come back to a few ideas: the grain of a table, how fact and dimension tables relate, which measures can be added up, and how changes over time are kept. You may be asked to design tables for a business process, or to find what is wrong with an existing model or query. The questions here take the second form, because a query result can be checked.
- How can a data modeling answer be checked automatically?
- Each question asks for a query whose result settles a modeling decision, such as how many rows share a key that was assumed to be unique. Your query runs in the browser and its first ten rows are compared with the expected result, in order. Column names do not have to match, but the columns must be in the order the question lists them and the rows must be sorted as asked.
- Which SQL dialect do these questions use?
- They run on SQLite in your browser. The joins, CTEs, and aggregation are standard SQL and work the same way in BigQuery, Snowflake, and Postgres. Date handling is the part that differs between engines: these answers use substr, date, and julianday where a warehouse would use DATE_TRUNC and DATEDIFF or DATE_DIFF.
- Do I need an account to answer them?
- No. Every question runs and is checked without an account. A free account adds hints, keeps track of what you have solved, and shows the worked answer once you have attempted a question.
- Is the data real?
- It is synthetic, generated to behave like business tables: orders with retried payments and refunds, stock movements, ad spend and leads, employees who join and leave, and versions of an AI agent. Each question runs on a linked sample of one of the free datasets on this site, and the full files can be downloaded for more practice.
