Star Schemas and Dimensional Modelling
In the first post of this series, we saw why organizations separate the systems that run the business from the systems that analyse it, and we met the main warehouse architectures. One name kept coming back: Kimball, and his star schemas. Whatever happens in the integration layer, the tables that analysts and dashboards actually query are, very often, stars.
This post is about how to design them. We will start from the very beginning, what a model is, and add one brick at a time until we have a complete dimensional model, including the part that confuses most people: history, and slowly changing dimensions.
Our example: a national bank. Everything in this post is built on one example. Our bank has agencies in several cities across the country: Douala, Yaoundé, Bafoussam, Garoua. Each agency employs portfolio managers. Every customer belongs to a portfolio, and each portfolio is attached to one agency and followed by one manager. Customers hold accounts (current accounts, savings accounts, loans), and those accounts record transactions: deposits, withdrawals, transfers, fees. Every table and every query below is written for that bank.
1) What is modelling?
A model is a simplified representation of something real, built for a purpose.
Think of a city and two maps of it. A street map shows every street, every turn, sometimes every building. A metro map shows almost none of that: straight lines, evenly spaced stations, and the places where lines connect. Distances are wrong and most of the city is missing. Yet if you want to get from one station to another, the metro map is the better map, precisely because of what it leaves out.
Two ideas from this example run through the whole post:
- A model is defined by its purpose. Neither map is “the real city”. Each keeps what matters for a question and drops the rest. The question comes first; the model follows.
- Simplifying well requires understanding. To draw the metro map, you must know which stations connect and which lines serve them. You cannot decide what to leave out of something you do not understand. A good model is a sign of good understanding.
2) What is a data model?
A data model applies this idea to an organization. It is an abstraction of how the organization works: what it deals with, what happens between those things, and the rules that govern them. For our bank: there are agencies, managers, portfolios, customers and accounts; customers make transactions on their accounts; a portfolio belongs to one agency.
A data model is therefore, first of all, a written-down understanding of the business. The better you understand how the bank actually works, the more precise your model will be. The reverse is just as true: wherever your understanding is vague, your model will be vague in exactly the same place. Most bad models are not caused by bad SQL. They are caused by questions nobody asked the business.
Modelling starts with questions
Before drawing a single table, you talk to the people who run the bank. Three questions are enough to show how much the answers shape the model:
- Can an account have more than one owner? If not, an account simply belongs to one customer. If it can (joint accounts between spouses, company accounts with several signatories), the link between customers and accounts goes both ways: one customer can hold many accounts, and one account can belong to many customers. The model needs an extra piece to represent that.
- Does a portfolio manager work in one agency, or can they follow portfolios in several agencies? The answer decides whether the agency of a portfolio can be deduced from its manager, or must be recorded separately.
- When a customer moves to another portfolio, does the bank need to know who managed them before? If managers are evaluated on the deposits collected in their portfolio, yes, and the model must keep history. We will come back to this question in section 9: it is the whole subject of slowly changing dimensions.
None of these questions are technical, yet each answer changes the model.
The building blocks
To express that understanding precisely, data modelling gives us a small set of concepts. There are five of them.
- Entity. A thing the business needs to keep track of: an agency, a portfolio manager, a customer, an account, a transaction. An entity is a type of thing. Each specific customer, such as Mrs Ngono, is one occurrence (or instance) of the Customer entity.
- Attribute. A property that describes an entity. A customer has a name, a city and a date of birth. An account has a number, a type and an opening date.
- Relationship. A meaningful link between two entities, usually named with a verb: a customer holds accounts; an agency employs portfolio managers.
- Cardinality. How many occurrences of one entity can be linked to one occurrence of the other. A relationship is one-to-one (1:1), one-to-many (1:N) or many-to-many (N:N). Cardinality is where business rules are written down: “a portfolio is attached to exactly one agency”, “a portfolio contains many customers”.
- Key. How one occurrence is identified. A primary key is an attribute (or a set of attributes) whose value is unique for each occurrence, such as the account number. A foreign key is how a relationship is stored: each account carries the primary key of the customer who holds it.
With these five concepts we can write down what we learned from the business. Figure 3 shows the model of our bank. Look at the account holder entity. It exists because the answer to the first question was “yes, an account can have several owners”. A many-to-many relationship cannot be stored with a single foreign key: an account cannot carry one customer key if it has two customers. So it is resolved with an entity in the middle, holding one occurrence per (customer, account) pair. The model now records a business rule that a quick look at the data might have missed.
Three levels of a data model
A model is written at three levels of detail, going from understanding the business to building the database:
- Conceptual: the entities and their relationships, in the language of the business. No columns, no technology. This is the level you discuss with the business, as in Figure 3.
- Logical: the same understanding described as tables, columns and keys, still independent of any particular database.
- Physical: the actual tables in a given engine, with data types, constraints, indexes and partitions.
3) The main modelling approaches
Understanding the business tells you what to model. There is still more than one way to organize the tables, and the different approaches exist because they serve different purposes, exactly like the two maps. To compare them, we need one more concept.
Normalization
Normalization is the process of organizing tables so that each piece of information is stored in exactly one place. Look at this table of transactions, where each row repeats the details of the agency:
| Transaction | Date | Amount (XAF) | Agency | Agency city | Agency region |
|---|---|---|---|---|---|
| TX-1 | 2026-03-03 | 250,000 | Bonanjo | Douala | Littoral |
| TX-2 | 2026-03-03 | 40,000 | Bonanjo | Douala | Littoral |
| TX-3 | 2026-03-04 | 75,000 | Akwa | Douala | Littoral |
| TX-4 | 2026-03-04 | 120,000 | Yaoundé Centre | Yaoundé | Centre |
The fact that Bonanjo is in Douala, in the Littoral region, is stored on every one of its transactions, possibly millions of times. If the bank reorganizes its regions, millions of rows must be updated, and if part of the update fails, the same agency ends up in two regions at once. These problems are called update anomalies.
Normalization removes them by splitting the table: transactions keep only an agency_id, and the agency’s city and region are stored once, in an agency table. Applied systematically, this leads to a series of rules called the normal forms. The usual target is the third normal form (3NF), where every column of a table describes the key of that table, the whole key, and nothing but the key.
The approaches
- Normalized (3NF, entity-relationship). The model of section 2 implemented directly: many tables, each fact stored once, linked by foreign keys. It is ideal for operational systems, which write constantly and must stay consistent. It is hard to analyse: a simple question like “deposits by region last month” requires joining transactions, accounts, agencies, cities and regions.
- Dimensional. Organized around business events (a transaction, a loan disbursement) and the context that describes them. It deliberately accepts some redundancy so that analytical questions are simple to write and fast to answer.
- Data Vault. Separates business keys (hubs), relationships (links) and descriptive history (satellites) into insert-only tables. Built to integrate many sources and keep a full audit trail, not to be queried by analysts.
- One Big Table (OBT). Everything flattened into one very wide table. Convenient for one dashboard or one machine learning dataset, but it duplicates logic and makes history and change hard to manage.
| Approach | Built for | Main users | Weak at |
|---|---|---|---|
| Normalized (3NF) | Writing safely, consistency | Applications | Analysis: many joins, technical names |
| Dimensional | Analysis | Analysts, BI tools | Absorbing frequent changes in the sources |
| Data Vault | Integration and audit | Data engineers | Direct querying |
| One Big Table | One specific use | One dashboard, one ML model | Reuse, history |
In a warehouse these approaches are often combined: a normalized or Data Vault layer to integrate the sources, and a dimensional layer on top for people and tools to query. Whatever is underneath, the layer analysts use is usually dimensional. It is the reference approach for analytics, and the subject of the rest of this post.
4) Dimensional modelling: facts and dimensions
Dimensional modelling starts from a simple observation: analysis is almost always about business events. A deposit, a withdrawal, a loan disbursed, an account opened. And questions about those events almost always have the same shape: how much, broken down by something. Deposits by agency. Withdrawals by month. Loans by product and region.
So dimensional modelling separates the information about each event into two kinds:
- Facts are the measurements of the event: the numbers you add up, average or count. The amount of a deposit. The principal of a loan.
- Dimensions are the context of the event: who, what, where, when, how. They are what you filter and group by. The customer, the account, the agency, the date, the channel.
A useful test is to describe one event as a sentence. Take one deposit:
On 3 March 2026, Mrs Ngono deposited 250,000 XAF into her savings account at the Bonanjo agency, at the counter.
The number in the sentence is the fact. Every other part is a dimension. Notice that most dimensions are entities from our data model (the customer, the account, the agency), and the others describe the event itself (the date, the type of transaction, the channel). Dimensional modelling does not throw away the understanding we built in section 2. It reorganizes it around events.
5) The star schema
A dimensional model is stored as a star schema:
- One fact table in the centre, with one row per event. It contains the facts and one foreign key per dimension. Fact tables are narrow and very long: our bank records millions of transactions a month.
- Several dimension tables around it, one per dimension. Each has a primary key and many descriptive attributes. They are wide and comparatively short: the bank has millions of transactions, but only thousands of customers and a few dozen agencies.
The important design choice is that dimensions are denormalized, the opposite of what we did in section 3. dim_agency holds the agency’s name, city and region in the same row, even though “Littoral” repeats for every agency of that region. dim_customer holds the customer’s segment and portfolio manager in the same row as their name. This redundancy is acceptable here for two reasons. Dimension tables are small, so repetition costs little. And a warehouse is not updated by thousands of users like an operational system; it is loaded by controlled processes, so the consistency that normalization protects is guaranteed by the load instead.
In exchange, every analytical question becomes the same simple query: join the fact table to the dimensions you need, filter, group and sum.
-- Deposits per region and month in 2026
SELECT a.region,
d.month,
SUM(f.amount) AS deposits
FROM fact_transaction f
JOIN dim_agency a ON f.agency_key = a.agency_key
JOIN dim_date d ON f.date_key = d.date_key
JOIN dim_transaction_type t ON f.transaction_type_key = t.transaction_type_key
WHERE t.type_name = 'Deposit'
AND d.year = 2026
GROUP BY a.region, d.month;
Every join goes from the fact table to one dimension, never further. Business users can read this structure, BI tools understand it, and query engines are optimized for it.
The snowflake schema
A snowflake schema is a star whose dimensions have been normalized again: the region moves to its own table, the city to another, and the agency only keeps foreign keys to them.
It saves a little storage and keeps each attribute in one place, but every query needs more joins and the model becomes harder to read. Kimball’s advice, which I follow, is to avoid snowflaking by default, and to use it only when there is a specific reason, for example a very large dimension in which a group of attributes changes independently from the rest.
6) The four-step design process
We know what a star looks like. How do you design one? Kimball describes a process in four steps, always in the same order. Let us follow it to build the transactions star of our bank from scratch.
Step 1: choose the business process
A business process is an activity that the organization performs and records: taking deposits and payments, granting loans, opening accounts, meeting customers. Each process produces its own events, and each becomes its own star. You do not model “the bank” in one go; you model one process at a time.
The choice is driven by the questions the business wants answered first. Suppose management asks: how much money moves through our accounts, in which agencies, through which channels? The process is account transactions: every deposit, withdrawal, transfer and fee posted on an account.
Step 2: declare the grain
The grain is the exact meaning of one row of the fact table. It is the most important decision in dimensional modelling, because every following step depends on it.
For our process, the grain is: one row per transaction posted on one account.
Declaring the grain is, again, a matter of understanding the business. Take a transfer of 100,000 XAF from Mrs Ngono’s current account to Mr Kamga’s savings account. Is it one transaction or two? In the bank’s core system it is two postings: a debit on one account and a credit on the other. With our grain it is therefore two rows, one per account. If nobody asks the question, transfers end up either counted twice or missing one side, depending on what the first developer happened to choose.
Two rules about grain:
- Choose the most detailed grain available, also called the atomic grain. One row per transaction can always be summed up to one row per day or per month; the reverse is impossible. Atomic data answers questions nobody has asked yet.
- Write it as one sentence and stick to it. Every row of the table must match that sentence. “One row per account per day” is a valid grain too, but for a different table, which we will meet in section 7.
Step 3: identify the dimensions
With the grain fixed, ask: what describes one transaction? Every answer that has a single value for one row at this grain is a dimension. For one posted transaction we know the date, the account, the customer, the product (savings account, current account…), the agency where it happened, the channel (counter, ATM, mobile app) and the type of transaction.
The grain also rules out wrong candidates. “Number of accounts held by the customer” does not describe one transaction; it describes a customer at a point in time, and belongs elsewhere.
A note on the customer: we saw in section 2 that an account can have several owners. For now, each transaction gets one customer_key, the account’s primary holder. We will handle joint accounts properly in section 11.
Step 4: identify the facts
Finally, ask: what do we measure for one transaction? Its amount, and the fee charged on it. Like dimensions, facts must be true at the declared grain. The account balance is tempting, but a balance does not describe a transaction; it describes an account at a point in time. That is a different grain, and therefore a different fact table.
The result is the star of Figure 7: process, grain, dimensions, facts, decided in that order.
7) Fact tables in depth
The grain decides what kind of fact table you build. There are three fundamental types, plus a special case.
Transaction fact tables
One row per event, recorded when the event happens. Our fact_transaction is one. Rows are inserted and never updated. Transaction tables are the most detailed and the most flexible, but some questions are expensive to answer from them: to know the balance of every account on 31 March, you would have to add up every transaction since each account was opened.
Periodic snapshot fact tables
One row per thing per period, whether something happened or not. For the bank: fact_account_balance_daily, with one row per account per day and its end-of-day balance. A dormant account with no transaction this week still gets a row every day. Snapshots answer “what was the situation at that moment?” directly, and much of banking reporting is built on them: deposits outstanding, the loan portfolio at month end, regulatory ratios.
Accumulating snapshot fact tables
One row per instance of a process with a clear beginning and end, updated as the process moves through its milestones. A loan application is a good example: it is submitted, analysed, approved, then disbursed. fact_loan_application has one row per application, one date key per milestone (submitted_date_key, approved_date_key, disbursed_date_key…) and facts such as the amount requested, the amount approved and the number of days between steps. When the application is approved, the existing row is updated. It is the only type of fact table whose rows change after they are inserted, and it makes questions such as “how many days, on average, from submission to disbursement in each agency?” easy to answer.
Factless fact tables
Some events have no measurement: they just happened. A customer met their portfolio manager on a given day, in a given agency. fact_customer_meeting has only foreign keys (date, customer, manager, agency) and no numeric column; you analyse it by counting rows. Factless tables can also record coverage, meaning what could have happened: which products each agency is allowed to sell. Compared with actual sales, it answers questions about events that did not happen, such as “which products sold nothing in Garoua this quarter?”
Additivity
Now that we have several kinds of fact tables, we can see that facts do not all behave the same way when you add them up.
- Additive facts can be summed across every dimension. The transaction amount is additive: summed by agency, by month or by customer, it always gives a meaningful total.
- Semi-additive facts can be summed across some dimensions but not across time. Balances are the classic case.
- Non-additive facts cannot be summed at all: ratios, percentages, interest rates, unit prices.
Here is one account in fact_account_balance_daily:
| Date | Account | End-of-day balance (XAF) |
|---|---|---|
| 29 March | ACC-1029 | 1,200,000 |
| 30 March | ACC-1029 | 1,450,000 |
| 31 March | ACC-1029 | 1,450,000 |
Summing the column gives 4,100,000 XAF, a number that means nothing: the account never held more than 1,450,000. Across time, you take the balance at the end of the period (1,450,000) or the average balance (about 1,366,667). Across accounts or agencies on the same day, summing is correct: the total balance of all Bonanjo accounts on 31 March is a real number.
For non-additive facts, the rule is to store the components, not the result. Do not store the interest rate of each loan and average it; an average of rates ignores the size of each loan. Store the interest amount and the principal, and compute the rate in the query: SUM(interest_amount) / SUM(principal).
Degenerate dimensions
One last piece of the fact table. Each transaction has a reference number from the core banking system, such as TX-88412. It is useful: an analyst investigating a suspicious transaction needs it. But it has no attributes of its own, so a dimension table for it would contain nothing but the number. We therefore keep it directly in the fact table, as a column. A dimension stored in the fact table without a dimension table is called a degenerate dimension. Transaction references, order numbers and invoice numbers are typical examples.
8) Dimension tables in depth
Fact tables hold the numbers, but dimensions hold everything users filter, group and read. A good dimension is what makes a model pleasant to use.
Surrogate keys and natural keys
In the core banking system, Mrs Ngono is identified by her customer number, CUS-0042. That is a natural key, also called a business key: the identifier of the source system, meaningful to the business.
In the warehouse, dim_customer does not use it as its primary key. The warehouse generates its own key, usually a plain integer: customer_key = 101. This is a surrogate key. It has no business meaning, it exists only inside the warehouse, and every fact table points to it. The natural key is still kept, as an ordinary column.
Why add a key when the source already has one?
- Several sources. The bank’s mobile money platform may know the same customer as
MM-7781. The warehouse integrates both under one surrogate key. - Source keys are not under your control. A system migration can renumber customers or reuse old account numbers. The warehouse keys stay stable.
- Special rows. Surrogate keys let you add rows that do not exist in any source, such as “Unknown” (see below).
- History. The most important reason, and the subject of section 9: when a customer changes, the warehouse may need two rows for the same customer, with the same natural key but two different surrogate keys.
- Performance. Small integer keys make fact tables smaller and joins faster than long text identifiers.
The date dimension
Every fact table has at least one date, and the date is the most used dimension of all. It may seem enough to store a date in the fact table and use date functions in queries. In practice you build a dim_date table, with one row per day (ten years is only about 3,650 rows) and many attributes computed once:
| date_key | full_date | day | month | quarter | is_business_day | is_last_business_day_of_month | holiday |
|---|---|---|---|---|---|---|---|
| 20260520 | 2026-05-20 | Wednesday | May | Q2 | No | No | National Day |
| 20260529 | 2026-05-29 | Friday | May | Q2 | Yes | Yes |
These attributes encode business knowledge that no date function has: Cameroon’s public holidays, the bank’s business days, its fiscal calendar. “Deposits on the last business day of each month” becomes a simple filter, with the same definition in every report. The key is often the date itself written as an integer (20260520), which keeps it readable.
Hierarchies
Many dimensions contain natural levels of detail. Agencies belong to cities, and cities to regions: agency → city → region. Products belong to families: “Savings account” and “Term deposit” are deposit products; “Mortgage” and “Overdraft” are credit products. In a star, each level is simply a column of the same dimension. Users drill down from region to city to agency, or roll up the other way, just by changing the column in the GROUP BY. These levels are exactly what the snowflake schema would have split into separate tables.
Role-playing dimensions
A banking transaction has two dates. The booking date is when it is recorded. The value date is the date from which it counts for interest. A cheque deposited on a Friday may be booked on Friday but only take value on Tuesday. So the fact table needs two foreign keys, booking_date_key and value_date_key, both pointing to the same dim_date. (Our first query in section 5 used a single date_key; from now on we use the booking date.)
One physical dimension used in several roles is called a role-playing dimension. You build it once and expose one view per role, with column names that say which role it plays, so a report can filter on “value date month” without ambiguity.
Junk dimensions
Transactions also carry small indicators: is it a reversal? Is it international? Was it made outside business hours? One dimension per yes/no flag would clutter the star, and many flag columns make the fact table wider for little benefit. A junk dimension groups them into one small table, with one row per combination that actually occurs (three yes/no flags give at most 8 rows). The fact table gets a single transaction_flags_key.
The unknown member
Not every transaction has every dimension. A transfer made in the mobile app does not happen in an agency. A transaction may arrive with a customer number the warehouse cannot match. Leaving the foreign key NULL is a trap: inner joins silently drop those rows, and totals stop matching the source.
Instead, each dimension gets special rows with reserved surrogate keys, for example -1 for “Unknown” and -2 for “Not applicable”. The mobile transfer points to “Not applicable” in dim_agency, and the unmatched transaction points to “Unknown” in dim_customer. Every fact row joins, totals stay correct, and reports show explicitly how much is unknown, which is itself a useful data quality indicator.
9) Slowly Changing Dimensions
The problem
Dimensions change. Not often, which is why they are called slowly changing dimensions (SCD), but they do. Back to the third question of section 2.
Until June 2025, Mrs Ngono lived in Douala, and her portfolio was managed by Mrs Fotso at the Bonanjo agency. In July 2025 she moved to Yaoundé, and her accounts were transferred to the portfolio of Mr Mbarga at the Yaoundé Centre agency.
Now the bank asks: how much did each portfolio manager collect in deposits during the first half of 2025? Mrs Ngono’s deposits from January to June were collected by Mrs Fotso. If the warehouse simply replaces “Fotso” with “Mbarga” in dim_customer, every past deposit of Mrs Ngono moves into Mr Mbarga’s figures. Mrs Fotso’s 2025 results are now wrong, and last year’s report, run again today, no longer gives last year’s numbers.
Overwriting is not always wrong, though. If the change is the correction of a typo in her name, nobody wants the misspelled name preserved on old transactions. The right behaviour is a business decision, taken attribute by attribute. The SCD types are the standard answers to that decision.
Type 0: keep the original
The value never changes in the warehouse, even if the source changes it. It is used for attributes that are fixed by definition: the date the customer joined the bank, the credit score given at onboarding.
Type 1: overwrite
The new value replaces the old one. No history is kept, and all past facts now show the new value.
| customer_key | customer_id | full_name | phone | |
|---|---|---|---|---|
| Before | 101 | CUS-0042 | Ngonno Marie | +237 6 77 12 34 56 |
| After | 101 | CUS-0042 | Ngono Marie | +237 6 99 87 65 43 |
Use it for corrections, and for attributes where only the current value matters to analysis, such as a phone number or an email address. It is simple and cheap. Used on the portfolio manager, it produces exactly the problem described above.
Type 2: add a new row
Type 2 is the one you will use most, and it relies on the surrogate keys of section 8. When a tracked attribute changes, the current row is closed and a new row is inserted, with a new surrogate key. Three columns manage the versions: valid_from, valid_to and is_current.
| customer_key | customer_id | full_name | city | portfolio_manager | valid_from | valid_to | is_current |
|---|---|---|---|---|---|---|---|
| 101 | CUS-0042 | Ngono Marie | Douala | Fotso | 2023-01-10 | 2025-06-30 | No |
| 245 | CUS-0042 | Ngono Marie | Yaoundé | Mbarga | 2025-07-01 | 9999-12-31 | Yes |
The two rows share the same natural key, CUS-0042: they are the same customer. In this role the natural key is often called the durable key, because it stays the same across all versions. The surrogate keys differ: each identifies one version of the customer. The far-future valid_to on the current row (9999-12-31) avoids NULLs in date comparisons.
The essential mechanism is in the fact table. When a transaction is loaded, it receives the surrogate key of the customer version that was valid on the date of the transaction. Deposits from March 2025 store customer_key = 101; deposits from September 2025 store 245.
-- During the load: give each transaction the customer version valid on its date
SELECT t.transaction_ref,
t.amount,
c.customer_key
FROM staging_transaction t
JOIN dim_customer c
ON c.customer_id = t.customer_id
AND t.booking_date BETWEEN c.valid_from AND c.valid_to;
As a result, history is correct without any effort in the queries. Grouping 2025 deposits by portfolio_manager credits Mrs Fotso until June and Mr Mbarga from July, because each fact row joins to the version that was true at the time. And when you want the whole history of Mrs Ngono regardless of version, you group by the durable key customer_id instead of the surrogate key.
The cost of Type 2 is size and complexity: each change adds a row, and the load must detect changes, close old versions and give facts the right keys. That is why you track only the attributes the business needs, not every column.
Type 3: add a “previous value” column
Type 3 keeps one previous value in an extra column of the same row. Suppose the bank reorganizes its regions, and Bafoussam moves from the “West” region to a new “West and North-West” region. For one year, management wants to see figures under both the old and the new organization.
| agency_key | agency_name | region | previous_region |
|---|---|---|---|
| 12 | Bafoussam | West and North-West | West |
Every fact, old or new, can now be reported under either organization by choosing the column. Type 3 is limited by design: it keeps a single previous value, and it suits a known, planned change rather than general history tracking.
Type 4: the mini-dimension
Some customer attributes change far too often for Type 2. Each month, the bank classifies every customer into a balance band (“under 1M”, “1M to 10M”, “over 10M”) and a risk band. With Type 2, a million customers reclassified monthly could add up to twelve million rows a year to dim_customer.
The solution is to move these fast-changing attributes into a separate, small dimension, the mini-dimension dim_customer_profile, with one row per combination of bands, not per customer. Three balance bands and four risk bands give twelve rows, however many customers the bank has. The fact table gets a second customer-related key, customer_profile_key, recording the profile valid at the time of the transaction. The main customer dimension stays stable, and the history of profiles is carried by the facts themselves.
A note on naming: some authors use “Type 4” for a separate history table that stores old versions while the main dimension keeps only the current one. The Kimball Group uses it for the mini-dimension, which is what we described here.
Types 5, 6 and 7: combinations
The remaining types combine the ones above to answer one recurring need: seeing history and the current value in the same report.
Type 6 (1 + 2 + 3). A Type 2 dimension with an extra current_ column, overwritten (Type 1) on every version of the customer. Each row keeps its historical value and also knows the latest one:
| customer_key | customer_id | city | current_city | valid_from | valid_to | is_current |
|---|---|---|---|---|---|---|
| 101 | CUS-0042 | Douala | Yaoundé | 2023-01-10 | 2025-06-30 | No |
| 245 | CUS-0042 | Yaoundé | Yaoundé | 2025-07-01 | 9999-12-31 | Yes |
A report can group 2025 deposits by city (where the customer lived at the time of each deposit) or by current_city (where the customer lives today), from the same table.
Type 5 (4 + 1). A mini-dimension (Type 4), plus a Type 1 column in the main customer dimension pointing to the customer’s current profile. Facts keep the profile at the time of the transaction; the dimension tells you the profile today.
Type 7 (dual keys). The fact table stores both the surrogate key (the version valid at the time) and the durable key (customer_id). Joining on the surrogate key gives the historical view. Joining on the durable key, restricted to is_current = 'Yes', gives the current view. It offers what Type 6 does without overwriting columns, at the cost of one more key in the fact table.
Choosing a type
The choice is made per attribute, with the business, around one question: when this value changes, should past facts keep the old value?
| Attribute | Question to the business | Type |
|---|---|---|
| Customer since, onboarding score | Can it ever change? No. | 0 |
| Phone, email, spelling of the name | Does the old value matter for analysis? No. | 1 |
| Portfolio manager, agency, city, segment | Should past figures stay with the old value? Yes. | 2 |
| Region after a planned reorganization | Do we need old and new side by side for a while? | 3 |
| Balance band, risk band (monthly) | Does it change too often for Type 2? | 4 (mini-dimension) |
| City, when reports need both views | History and current value in one report? | 6 or 7 |
Implementing Type 2
Each time the dimension is refreshed, a Type 2 load runs in two steps. First, compare the incoming source rows with the current versions, and close those whose tracked attributes changed. Then insert a new current version for every changed or new customer. In SQL (PostgreSQL syntax):
-- Step 1: close the current version of customers whose tracked attributes changed
UPDATE dim_customer d
SET valid_to = CURRENT_DATE - 1,
is_current = 'No'
FROM staging_customer s
WHERE d.customer_id = s.customer_id
AND d.is_current = 'Yes'
AND (d.city IS DISTINCT FROM s.city
OR d.portfolio_manager IS DISTINCT FROM s.portfolio_manager);
-- Step 2: insert a new current version for changed and new customers
INSERT INTO dim_customer
(customer_id, full_name, city, portfolio_manager,
valid_from, valid_to, is_current)
SELECT s.customer_id, s.full_name, s.city, s.portfolio_manager,
CURRENT_DATE, DATE '9999-12-31', 'Yes'
FROM staging_customer s
LEFT JOIN dim_customer d
ON d.customer_id = s.customer_id
AND d.is_current = 'Yes'
WHERE d.customer_id IS NULL;
The surrogate key is generated by the database, with an identity column or a sequence. Step 2 works because, after step 1, changed customers no longer have a current row, so they look exactly like new customers. IS DISTINCT FROM compares NULLs safely, where <> would miss a change from or to NULL. Many teams also compare a hash of the tracked columns instead of each column, and on engines that support it, both steps can be written as one MERGE statement.
If you use dbt, snapshots implement this pattern for you:
{% snapshot customer_snapshot %}
{{ config(
target_schema='snapshots',
unique_key='customer_id',
strategy='check',
check_cols=['city', 'portfolio_manager', 'segment'],
) }}
SELECT * FROM {{ source('core_banking', 'customers') }}
{% endsnapshot %}
On each run, dbt compares the listed columns with the current version, closes changed rows and inserts new ones, adding dbt_valid_from and dbt_valid_to columns (by default, the current row has a NULL dbt_valid_to). If the source has a reliable updated_at column, the timestamp strategy is cheaper than comparing columns. The snapshot is the history; you then build dim_customer on top of it, adding the surrogate key and the unknown member.
10) Several stars: conformed dimensions and the bus matrix
So far we have built one star. The bank has other processes: loans are disbursed and repaid, balances are measured every day, customers meet their managers. Following the four steps, each process becomes its own star: fact_loan_disbursement, fact_account_balance_daily, fact_customer_meeting.
The real value appears when these stars can be combined. A regional director wants one report: for each agency and month, the deposits collected and the loans disbursed. That is only possible if both stars describe agencies and months in exactly the same way.
Conformed dimensions
A conformed dimension is a dimension shared by several fact tables, with the same keys, attributes and values wherever it is used. There is one dim_agency, one dim_date, one dim_customer, and every star uses them. “Bonanjo” has the same spelling, the same region and the same key in the transactions star and in the loans star.
Conformed dimensions are what turn a collection of stars into a warehouse. Without them, each star is an isolated data mart with its own idea of what an agency is, and we are back to the “five versions of revenue” problem from the first post.
The bus matrix
The bus matrix is the planning tool for this. Rows are business processes, columns are dimensions, and a mark means the process uses that dimension. Note that the portfolio manager, an attribute of dim_customer in our first star, is also a dimension of its own for processes such as meetings, where the manager is directly involved.
| Business process | Date | Customer | Account | Agency | Product | Manager | Channel |
|---|---|---|---|---|---|---|---|
| Account transactions | ● | ● | ● | ● | ● | ● | |
| Daily account balances | ● | ● | ● | ● | ● | ||
| Loan applications | ● | ● | ● | ● | ● | ● | |
| Loan disbursements | ● | ● | ● | ● | ● | ● | |
| Customer meetings | ● | ● | ● | ● |
Read by columns, the matrix shows which dimensions must be conformed first: date, customer and agency are used everywhere. Read by rows, it is a roadmap: each row is a star you can build and deliver on its own, one process at a time, while the shared columns guarantee that the pieces fit together. This is the bus architecture from the first post.
Drill-across
Combining stars through their conformed dimensions is called drilling across. The rule is: aggregate each fact table separately to the same level, then join the results.
WITH deposits AS (
SELECT a.agency_name, d.year, d.month, SUM(f.amount) AS deposits
FROM fact_transaction f
JOIN dim_agency a ON f.agency_key = a.agency_key
JOIN dim_date d ON f.booking_date_key = d.date_key
JOIN dim_transaction_type t ON f.transaction_type_key = t.transaction_type_key
WHERE t.type_name = 'Deposit'
GROUP BY a.agency_name, d.year, d.month
),
loans AS (
SELECT a.agency_name, d.year, d.month, SUM(f.principal) AS loans_disbursed
FROM fact_loan_disbursement f
JOIN dim_agency a ON f.agency_key = a.agency_key
JOIN dim_date d ON f.disbursement_date_key = d.date_key
GROUP BY a.agency_name, d.year, d.month
)
SELECT COALESCE(dp.agency_name, l.agency_name) AS agency,
COALESCE(dp.year, l.year) AS year,
COALESCE(dp.month, l.month) AS month,
dp.deposits,
l.loans_disbursed
FROM deposits dp
FULL OUTER JOIN loans l
ON dp.agency_name = l.agency_name
AND dp.year = l.year
AND dp.month = l.month;
Why not join the two fact tables directly? Because they have different grains. One agency has thousands of transactions in a month and a few dozen loans. Joining them row to row pairs every deposit with every loan of that agency-month, so each deposit is repeated once per loan and each loan once per deposit, and both totals are wrong. This is called fan-out. Aggregating first brings both sides to the same grain (one row per agency and month), where the join is one-to-one and safe. The full outer join keeps agencies that had deposits but no loans, and the reverse.
11) Advanced patterns
Bridge tables: many-to-many relationships
Back to the first question of section 2: an account can have several owners. Mr and Mrs Kamga share a joint current account. So far, each transaction carried one customer_key, the primary holder. What if the bank wants deposits by customer, counting joint accounts for both holders?
The answer is the one we already found in the data model: an entity in the middle. A bridge table sits between the account and the customer dimension, with one row per (account, holder) pair. The fact table keeps its account_key, and the bridge links each account to all of its holders.
The bridge comes with a risk: joining through it repeats each transaction once per holder. A 100,000 XAF deposit on the Kamgas’ account appears twice, and the bank’s total doubles. There are two ways to use it:
- Weighted reporting. The bridge carries a
weight(0.5 for each of two holders, summing to 1 per account), and queries sumamount * weight. Totals stay correct, and each holder is credited with half. - Impact reporting. Ignore the weight on purpose, to answer “how much money moved through the accounts this customer holds?”. Each holder sees the full amount; the grand total is then meaningless and should not be displayed.
Both are legitimate. What matters is that each report states which one it uses.
Irregular hierarchies
The agency → city → region hierarchy is regular: every agency has exactly one city and one region, so each level is a column. Some hierarchies are not. The bank’s organization chart is one: most agencies report to a regional directorate, small satellite agencies report to a larger agency first, and the main Douala agency reports directly to head office. The number of levels varies from branch to branch. This is called a ragged or variable-depth hierarchy, and plain columns cannot represent it, because you do not know how many to create.
There are two standard solutions. If the depth is limited, flatten the hierarchy into a fixed number of level columns, and fill the missing levels by repeating the nearest value, so every level is populated:
| agency | level_1 | level_2 | level_3 | level_4 |
|---|---|---|---|---|
| Douala main | Head office | Douala main | Douala main | Douala main |
| Bonanjo | Head office | Littoral directorate | Bonanjo | Bonanjo |
| Akwa Nord | Head office | Littoral directorate | Akwa | Akwa Nord |
If the depth is truly variable, use a hierarchy bridge table, with one row for every (ancestor, descendant) pair and the number of levels between them. Summing everything under the Littoral directorate then becomes a simple join on that ancestor. In banking, the chart of accounts of the general ledger is usually handled this way.
Late-arriving data
The load process assumes that dimensions arrive before the facts that use them, and that facts arrive on time. Reality is less tidy.
Late-arriving facts. An agency in a rural area loses its connection for three days, and its Monday transactions reach the warehouse on Thursday. Loading them is ordinary, with one rule: the dimension lookup must use the transaction date, not the load date. If a customer’s version changed on Tuesday, Monday’s transactions must point to the version valid on Monday. The Type 2 lookup of section 9 already does this, as long as it compares with the business date. If the fact table is partitioned by date, the old partitions are reloaded, and any aggregate built on them is refreshed.
Late-arriving dimensions (or early-arriving facts). A customer opens an account in the mobile app and makes a deposit immediately. The transaction arrives tonight, but the customer record from the onboarding system only arrives tomorrow. Pointing the transaction to “Unknown” would lose the link forever. Instead, the load inserts an inferred member: a new row in dim_customer with the natural key found on the transaction, a new surrogate key, placeholder attributes (“Pending”) and an is_inferred flag. The fact points to it. When the real customer record arrives, the inferred row is updated in place (Type 1, since the placeholders were never real history) and the flag is cleared. The fact never has to change.
Aggregate tables
In the first post we drew an optional dotted layer on top of the stars: aggregate fact tables. With the vocabulary of this post, they are easy to define. An aggregate is a fact table at a coarser grain, built from the atomic one. agg_transaction_monthly holds one row per agency, product, transaction type and month, with the summed amounts and the number of transactions. It uses the same conformed dimensions, or reduced versions of them (a month dimension derived from dim_date), so reports can switch between aggregate and detail without changing meaning. Build aggregates only for queries you have measured as slow, and always rebuild them from the atomic facts.
12) Dimensional modelling today
Kimball’s book was published in 1996, when storage was expensive and databases read data row by row. Today’s platforms (BigQuery, Snowflake, Redshift, Databricks) store data by column, scale compute on demand and make storage cheap. Is dimensional modelling still worth the effort?
Some of its original motivations have weakened: joins are cheap, scans are fast, and a denormalized One Big Table is perfectly practical on a columnar engine. But the most important reasons were never about performance:
- Shared understanding. Facts and dimensions match the way the business already thinks: amounts, by agency, by month. The model is the business vocabulary, written down.
- Consistency. Conformed dimensions are what make deposits and loans agree on what an agency is. Faster hardware does not solve that problem.
- History. Slowly changing dimensions are a modelling decision. No engine decides for you whether Mrs Fotso keeps her 2025 deposits.
- Reuse. One star serves dozens of reports. One wide table per dashboard means the same logic copied, and slowly diverging, in every table.
In practice the two coexist well: model in stars, then build wide tables from the stars where a specific dashboard or machine learning model needs one. In a Medallion architecture, the stars are the gold layer: silver integrates and cleans, gold presents the data as facts and conformed dimensions. Semantic layers, which define each metric once for every BI tool, are built on top of exactly this structure.
13) Common mistakes
- Not declaring the grain, or mixing grains. A fact table holding both transaction rows and monthly total rows counts everything twice. Write the grain as one sentence; every row must match it.
- Using natural keys as foreign keys. It works until the first source migration, the second source system, or the first Type 2 change. Use surrogate keys from the start.
- Snowflaking by reflex. Normalizing dimensions out of habit from operational design adds joins and makes the model harder to use.
- Type 2 on every column. Tracking the history of phone numbers multiplies rows for nothing. Decide the type per attribute, with the business.
- Overwriting what the business needs to keep. The opposite mistake: Type 1 on the portfolio manager silently rewrites last year’s performance.
- Summing semi-additive facts over time. Adding up daily balances gives meaningless totals. Take the end-of-period value or the average.
- Storing ratios instead of their components. An average of rates ignores the weight of each row. Store the numerator and the denominator, and compute the ratio in the query.
- NULL foreign keys. Inner joins drop those rows, and totals stop matching the source. Point them to the unknown or not-applicable member.
- Joining fact tables directly. Different grains fan out. Aggregate each side to the same level, then join.
- Modelling the source system instead of the business. Copying the core banking tables into the warehouse and renaming them “dimensions” is not modelling. Start from the processes and the questions, as in section 2.
14) Conclusion
We started from a question that has nothing to do with SQL, what is a model, and built one brick at a time: an understanding of how the bank works, entities and relationships, facts and dimensions, a star, and finally the decisions that keep it correct over time. Every difficult choice along the way, the grain, the SCD types, the bridge weights, was answered by asking the business, not the database. That is the idea worth keeping: a model is only as good as your understanding of what it models.
Thank you for reading. I hope this post helps you design your own models, and that the next time someone asks why the same customer appears twice in dim_customer, you know exactly what to answer. See you in the next one!