Data warehouse
Хранилище данных
A data warehouse brings data from different systems together and keeps it organized over time so people can run reports, compare trends, and answer business questions.
Also known as: DWH, data lake
What a data warehouse does
A data warehouse (DWH) gives analysts a consistent place to answer questions that span several systems. A subscription company, for example, might keep invoices in its billing platform and plan changes in its application database. By combining those records, analysts can compare billed amounts across plans without asking each team to export and reconcile its own spreadsheets.
How data gets there
Pipelines pull data from sources such as application databases, APIs, and event streams. In ETL, the pipeline extracts and transforms the data before loading it into the warehouse. In ELT, it loads the data first and transforms it in the warehouse. Either way, transformations might reconcile customer IDs, remove duplicate events, and standardize timestamps. Teams can then publish curated tables for BI dashboards or ad hoc SQL analysis. Data freshness depends on how often the pipelines run and when the source data arrives.
Example: reporting by subscription plan
Say finance wants monthly billed amounts by plan. First define the grain: one row per invoice line, not one row per invoice or customer. A fact table at that grain can store the line amount and keys to the billing date and plan. Date and plan details live in dimension tables. That arrangement is a star schema. To build the report, join the fact table to the dimensions, group by billing month and plan, and sum the line amounts.
The grain also tells you what not to do. If you repeat an invoice total on every line and sum that column, invoices with multiple lines will be overcounted. And if the report needs the plan as it was when the invoice was issued, joining to the customer's current plan won't work: an upgrade could move past charges into a different category.
Warehouse, operational database, or data lake?
An operational database handles requests such as creating an invoice or updating a subscription. A warehouse is designed for analytical workloads, such as scanning a year of invoice lines and aggregating them by month. Separating these workloads can keep reporting queries from competing with live application traffic. A data lake is not another name for a warehouse: it commonly holds data in a range of formats, including raw files and events. A lake can feed a warehouse, and some architectures support both roles on shared storage.
What comes up in interviews
When asked to design a warehouse table, start with the question it needs to answer and say what one row represents. Then explain how you'll handle updates and late-arriving records. A useful test is to ask what happens if a source corrects last month's invoice or the same batch runs twice.