A data warehouse organizes data for reporting and analysis. A common starting point is a star schema with measurable events in fact tables and descriptive attributes in dimension tables.
Choose the grain first
Specify precisely what one fact row represents, such as one sales line. Incorrect grain creates double counting and ambiguous measures.
A compact model
CREATE TABLE dbo.DimProduct (
ProductKey int NOT NULL PRIMARY KEY,
ProductCode nvarchar(30) NOT NULL,
CategoryName nvarchar(80) NOT NULL
);
CREATE TABLE dbo.FactSales (
SalesLineKey bigint NOT NULL PRIMARY KEY,
ProductKey int NOT NULL REFERENCES dbo.DimProduct(ProductKey),
Quantity int NOT NULL,
NetAmount decimal(14,2) NOT NULL
);
Build the pipeline
Extract source data; standardize types and business keys; detect duplicates; populate dimensions; then load fact rows with validated dimension lookups. Plan late-arriving data and changed attributes.
Validate totals
Compare facts to source-system reconciliation totals, check orphan keys and null behaviour, and document definitions such as net revenue versus gross sales.
Reporting and performance
Choose indexes, partitions, or columnstore structures based on data volume and read patterns. Avoid mistaking a normalized transaction schema for an optimal warehouse design.
AI disclosure and reuse: This AI-generated article is rewritten from an existing Open Education post (ID 23978). Additional explanations, code examples, and version notes may have been added. You may reuse the newly generated article text with or without attribution. Third-party trademarks and linked works retain their own rights. AI can make mistakes. Check examples, permissions, supported SQL Server versions, and documentation before use in any live system.
