At the end of the previous lesson a question was left hanging: if the status of five orders changes, how are they updated in a data lake made of immutable files? The question marks the limit of the lake and leads us to the other great analytical system, the more seasoned one: the data warehouse, a database designed expressly for analysis, with transactions, SQL and data modelled for the business.

In this lesson you will get to know the data warehouse and its characteristic modelling technique, the star schema, which you will apply to NovaMarket's sales. You will then see why maintaining a lake and a warehouse separately is costly, and how the lakehouse architecture, built on open table formats (Delta Lake, Apache Iceberg, Apache Hudi), gives the lake's files the guarantees of a database. You will check this for yourself by updating orders with a MERGE operation and travelling back to an earlier version of the table. That brings the storage module to a close.

What a data warehouse is

A data warehouse (DW for short) is a centralised database optimised for analysis, which integrates data from several of the company's systems, already clean and structured, and keeps its history.

Its features, compared with the data lake from lesson 02-04:

  • Schema-on-write. The tables are designed before the data is loaded. Whatever does not fit does not get in.
  • Integrated, reliable data. It is the "official version" of the company's figures: if two reports give different sales, the data warehouse has the final say.
  • It is queried with SQL, and it is tuned so that queries over millions of rows come back in seconds.
  • ACID transactions (lesson 02-03): a load is applied in full or not at all, and whoever is querying never sees half-finished data.

The data arrives through periodic processes that extract it from the source systems, transform it and load it, known as ETL or ELT; they are studied in lesson 03-06.

OLTP versus OLAP

Why not analyse directly on the shop's database? Because databases serve two opposite kinds of work:

OLTP (Online Transaction Processing) OLAP (Online Analytical Processing)
Purpose Running the business Understanding the business
Typical operation Reading or writing a few rows by their key Reading millions of rows and aggregating them
Example at NovaMarket "Record order 20,001 for customer 512" "Sales by category and month over the last year"
Users Thousands of customers and applications at once Dozens of analysts
Expected response Milliseconds Seconds or minutes
Data Current state Years of history
Table design Normalised, to avoid duplication and write fast Denormalised, to read fast
Internal storage By rows By columns
System The shop's database (and the serving NoSQL stores) Data warehouse

Running the analytical query on the shop's database would lock it up while customers are trying to buy, and it would be slow as well: that database stores data by rows, and you already know from lesson 02-02 that analysis calls for columns. That is why the data is copied to a separate system.

Dimensional modelling: facts, dimensions and the star schema

The data in a data warehouse is not organised as it is in the source database. The most widespread technique is dimensional modelling, which divides tables into two classes:

Fact table Dimension table
What it represents Something that happened and can be measured The context of what happened
Question it answers How much? How many? Who? What? When? Where?
Content Numeric measures and keys to the dimensions Descriptive attributes
Size Huge: one row per occurrence Small or medium
Example A sales line: quantity, amount Product, customer, date

When you draw it, the fact table sits in the centre with the dimensions around it, like the points of a star: hence the name star schema.

The most important decision when designing a fact table is its grain: exactly what one row represents. You must be able to state it in one sentence, and choose the finest level of detail available: you can always aggregate later, but you can never disaggregate.

Every query on a star follows the same pattern: aggregate the measures from the facts, filtering and grouping by attributes of the dimensions. That regularity is its great virtue: analysts grasp it straight away and engines optimise it very well.

NovaMarket's sales star schema

Irene wants Marc to be able to analyse sales by product, customer and time. The model:

  • Grain: one row per order line (one product within an order).
  • Facts: fact_sales, with the measures quantity, unit_price and line_amount.
  • Dimensions: dim_product, dim_customer and dim_date.
erDiagram
    DIM_DATE ||--o{ FACT_SALES : "when"
    DIM_CUSTOMER ||--o{ FACT_SALES : "who"
    DIM_PRODUCT ||--o{ FACT_SALES : "what"
    FACT_SALES {
        int order_id
        int date_id FK
        int customer_id FK
        int product_id FK
        string channel
        string status
        int quantity
        double unit_price
        double line_amount
    }
    DIM_DATE {
        int date_id PK
        date date
        int year
        int month
        int day
        boolean is_weekend
    }
    DIM_CUSTOMER {
        int customer_id PK
        string name
        string province
        date signup_date
    }
    DIM_PRODUCT {
        int product_id PK
        string name
        string category
        double price
    }

Several design details:

  • fact_sales combines orders and order_lines. In the shop's database they are two tables (a normalised design); in the data warehouse they are merged into one, repeating the order's data on every line. Information is duplicated in exchange for saving a join in every query.
  • dim_date is a table, not just a column. It has one row per day, with attributes already calculated: year, month, whether it is a weekend and, in a real case, quarter, public holidays or sales campaigns. That makes "weekend sales" a trivial filter. Its key, date_id, is an integer of the form YYYYMMDD (20260615).
  • channel and status stay in the fact table. They are attributes with so few values that they do not deserve a table of their own; they are called degenerate dimensions.
  • order_id does not point to any dimension: it is used to count distinct orders and to trace back to the source.

Building it and querying it

In a data warehouse, these tables would be created with CREATE TABLE statements and loaded with SQL. To practise without installing anything, we will build them with Spark from the silver zone, store them in the gold zone of your lake and query them with SQL, which Spark also understands. Create ~/novamarket/star_schema.py:

from pathlib import Path

from pyspark.sql import SparkSession
from pyspark.sql import functions as F

LAKE = Path.home() / "novamarket" / "lake"
SILVER = LAKE / "silver"
GOLD = LAKE / "gold"

spark = (
    SparkSession.builder
    .master("local[*]")
    .appName("star_schema")
    .getOrCreate()
)
spark.sparkContext.setLogLevel("ERROR")

orders = spark.read.parquet(str(SILVER / "orders"))
lines = spark.read.parquet(str(SILVER / "order_lines"))

# 1. Customer and product dimensions: they start from the silver tables
dim_customer = spark.read.parquet(str(SILVER / "customers"))
dim_product = spark.read.parquet(str(SILVER / "products"))

# 2. Date dimension: one row per day with orders
dim_date = (
    orders
    .select(F.to_date("order_date").alias("date"))
    .distinct()
    .select(
        F.date_format("date", "yyyyMMdd").cast("int").alias("date_id"),
        "date",
        F.year("date").alias("year"),
        F.month("date").alias("month"),
        F.dayofmonth("date").alias("day"),
        F.dayofweek("date").isin(1, 7).alias("is_weekend"),
    )
)

# 3. Fact table: one row per order line
fact_sales = (
    lines.join(orders, "order_id")
    .select(
        "order_id",
        F.date_format("order_date", "yyyyMMdd").cast("int").alias("date_id"),
        "customer_id",
        "product_id",
        "channel",
        "status",
        "quantity",
        "unit_price",
        F.round(F.col("quantity") * F.col("unit_price"), 2).alias("line_amount"),
    )
)

# 4. They are saved in the gold zone and registered as views so SQL can be used
tables = {"dim_customer": dim_customer, "dim_product": dim_product,
          "dim_date": dim_date, "fact_sales": fact_sales}
for name, df in tables.items():
    df.write.mode("overwrite").parquet(str(GOLD / name))
    spark.read.parquet(str(GOLD / name)).createOrReplaceTempView(name)
    print(f"gold <- {name}: {spark.table(name).count()} rows")

# 5. A typical analytical query on the star
spark.sql("""
    SELECT p.category,
           d.month,
           SUM(f.quantity)                AS units,
           ROUND(SUM(f.line_amount), 2)   AS sales
    FROM fact_sales f
    JOIN dim_product p ON f.product_id = p.product_id
    JOIN dim_date    d ON f.date_id    = d.date_id
    WHERE f.status <> 'returned'
      AND d.month IN (5, 6)
    GROUP BY p.category, d.month
    ORDER BY d.month, sales DESC
""").show()

spark.stop()

Spark's transformations are explained in Module 3; for now, concentrate on the logic:

  • Block 2. The distinct days are extracted from orders and, for each one, its attributes are calculated. dayofweek returns 1 for Sunday and 7 for Saturday. (A real data warehouse would have one row for every day in the calendar, whether or not there are orders.)
  • Block 3. lines.join(orders, "order_id") joins each line to its order: this is the merging of the two tables. It works cleanly because silver no longer has any duplicate orders; on bronze, the lines of the 100 repeated orders would have been counted twice. line_amount is calculated from the lines, so it is not affected by the 200 orders with no total_amount.
  • Block 4. createOrReplaceTempView gives a set of files a table name for the duration of the session: a minimal, temporary version of the metadata catalogue from lesson 02-04.
  • Block 5. The query follows the star pattern: it aggregates measures from the facts (SUM), and filters and groups by attributes of the dimensions (category, month).

The result of a real run:

gold <- dim_customer: 1000 rows
gold <- dim_product: 200 rows
gold <- dim_date: 181 rows
gold <- fact_sales: 50107 rows
+----------+-----+-----+----------+
|  category|month|units|     sales|
+----------+-----+-----+----------+
|television|    5| 1515|1785911.07|
| computing|    5| 1562|1003544.22|
|    phones|    5| 1559| 898112.01|
|     audio|    5| 2490| 755191.17|
|appliances|    5| 1573| 694492.56|
|      home|    5| 2065| 452978.78|
|television|    6| 1365|1600253.92|
| computing|    6| 1438| 901371.84|
|    phones|    6| 1403| 813384.48|
|     audio|    6| 2371| 720510.56|
|appliances|    6| 1517| 680554.23|
|      home|    6| 1905| 405623.81|
+----------+-----+-----+----------+

fact_sales has 50,107 rows, the same as order_lines: the grain has been respected. (Do not look for trends in the figures: the data is random, and June has one day fewer than May.)

MPP architecture and cloud data warehouses

How does a data warehouse manage to respond in seconds over billions of rows? With an MPP (Massively Parallel Processing) architecture: a cluster in which a coordinator node chops each SQL query up and hands it out to many compute nodes, which work in parallel on their portion of the data and return partial results to be combined. These are the partitioning ideas from lesson 01-04, applied to a SQL database with columnar storage.

The first MPP data warehouses were expensive appliances installed in the company's data centre. Today cloud data warehouses, bought as a service, dominate:

Service Provider
Snowflake Independent; runs on AWS, Azure and Google Cloud
Google BigQuery Google Cloud
Amazon Redshift Amazon Web Services
Azure Synapse Analytics (and its evolution in Microsoft Fabric) Microsoft Azure

They all share the separation of compute and storage from lesson 02-01 and pay-as-you-go pricing. Their differences and pricing models are covered in lesson 06-04.

The limitations of the data lake and of the two-tier architecture

What the plain data lake lacks

Your lake/silver/orders table is a folder of Parquet files. As a database, it has serious shortcomings:

Shortcoming What happens in practice
No transactions If a job fails halfway through a write, half-written files are left behind. Anyone reading at that moment will see incomplete or repeated data
No reliable updates or deletes The files are immutable: changing the status of five orders means rewriting whole files, by hand and with no safety net
No schema enforcement Nothing stops a job writing files with different columns or types into the same folder
No history After an overwrite, the previous version is gone
Slow listings To find out which files make up the table you have to list directories, which is slow in object stores with thousands of files

The second shortcoming also has a legal side: when a customer exercises their right to have their data erased, you have to be able to delete it for real. (This is a regulated matter that is covered in lesson 07-02 and must be reviewed with the data protection officer.)

The cost of maintaining a lake and a warehouse

Because of those shortcomings, the usual architecture for years has been a two-tier one: everything arrives in the data lake, and the refined data is copied to a data warehouse for the business to consume.

flowchart LR
    F[Sources] --> L[Data lake<br/>files]
    L -- "copy: ETL" --> W[Data warehouse]
    L --> ML[Data science and ML]
    W --> BI[Reports and SQL]

It works, but it comes at a price:

  • Duplicated data: it is stored and paid for twice.
  • More processes to maintain: every copy is a process that can fail.
  • Lag: the warehouse is always behind the lake.
  • Figures that do not tally: the ML model is trained on the lake and the report comes out of the warehouse; sooner or later they disagree.
  • Two systems to administer, secure and govern, and often dependence on a proprietary format in the warehouse.

Lakehouse and open table formats

The lakehouse architecture (from lake and warehouse) proposes doing away with the copy: giving the data lake's files the capabilities of a data warehouse, so that a single system serves both SQL reporting and data science.

The piece that makes this possible is the open table format. It is important not to confuse it with the file format:

  • A file format (Parquet) defines how the data is organised inside a file.
  • A table format defines which files make up a table at any given moment and how that set is changed safely. The data is still in Parquet.

The three main ones are Delta Lake (created by Databricks), Apache Iceberg (created at Netflix) and Apache Hudi (created at Uber). They differ in implementation, but share the central idea.

The transaction log

Alongside the Parquet files, the table has a transaction log: an ordered sequence of small metadata files. Each one describes a change, a commit: "these data files are added; these others are no longer valid".

orders_delta/
├── _delta_log/
│   ├── 00000000000000000000.json    version 0: "file A added"
│   └── 00000000000000000001.json    version 1: "A removed, B added"
├── part-00000-...A.snappy.parquet
└── part-00000-...B.snappy.parquet

The rule is simple and powerful: the table is not "what is in the folder", but "what the log says". A reader first consults the log to find out which files are valid and reads only those. Everything else follows from that:

Capability How the log provides it
ACID transactions A change does not exist until its entry is written to the log, and that write is atomic. If the job fails before then, the half-written files are left orphaned and nobody reads them
Consistent reads Whoever is reading works with a specific version, even if another job is writing at the same time
UPDATE, DELETE and MERGE Only the affected files are rewritten and the log notes "remove these, add these". The files are still immutable; what changes is the list
Time travel The removed files are not deleted immediately: by replaying the log up to an earlier version, the table is read as it was
Schema enforcement and evolution The schema is in the log. A write that does not respect it is rejected; adding a column is a logged change (this ties in with the schema evolution from lesson 02-02)
Fast planning The log holds the list of files and their statistics: there is no need to list directories

The MERGE operation

MERGE, also called an upsert (from update and insert), is the flagship operation of a lakehouse. It compares a table with a batch of updates and, in a single transaction, updates the rows that already exist and inserts those that do not. It is exactly what NovaMarket's daily load needs: every night new orders arrive along with status changes to old orders.

MERGE INTO orders AS t
USING updates AS u
ON t.order_id = u.order_id
WHEN MATCHED THEN UPDATE SET t.status = u.status
WHEN NOT MATCHED THEN INSERT *;

Optional hands-on: Delta Lake with PySpark

You are going to turn orders into a Delta table, apply a MERGE to it and query its history.

Optional exercise, with a warning about versions. Each version of delta-spark only works with certain versions of pyspark. Check the compatibility table in the Delta Lake documentation before installing. When you install the package, pip may replace your version of PySpark with a compatible one: in the test carried out for this lesson, it downgraded it by one minor version, with no effect on the other scripts in the course. If you would rather not touch your environment, create a separate one (python3 -m venv .venv-delta) and install it there. The first run needs an internet connection, because it downloads Delta's Java components.

python -m pip install delta-spark
python -m pip list | grep -i -E "pyspark|delta"

The second line shows the versions that have ended up installed. Create ~/novamarket/orders_delta.py:

from pathlib import Path

from delta import DeltaTable, configure_spark_with_delta_pip
from pyspark.sql import SparkSession
from pyspark.sql import functions as F

LAKE = Path.home() / "novamarket" / "lake"
PARQUET_PATH = str(LAKE / "silver" / "orders")
DELTA_PATH = str(LAKE / "silver" / "orders_delta")

# 1. Spark session with the Delta Lake extensions enabled
builder = (
    SparkSession.builder
    .master("local[*]")
    .appName("orders_delta")
    .config("spark.sql.extensions", "io.delta.sql.DeltaSparkSessionExtension")
    .config("spark.sql.catalog.spark_catalog",
            "org.apache.spark.sql.delta.catalog.DeltaCatalog")
)
spark = configure_spark_with_delta_pip(builder).getOrCreate()
spark.sparkContext.setLogLevel("ERROR")

# 2. Version 0: the orders from the silver zone, written as a Delta table
orders = spark.read.parquet(PARQUET_PATH)
orders.write.format("delta").mode("overwrite").save(DELTA_PATH)

# 3. Updates arriving from the shop's system:
#    the pending orders from 30 June have now been shipped...
shipped = (
    orders
    .where("status = 'pending' AND order_date >= '2026-06-30'")
    .withColumn("status", F.lit("shipped"))
)
#    ...and a new order has come in
new_order = spark.createDataFrame(
    [(20001, 512, "2026-07-01 00:04:10", 249.90, "pending", "app")],
    "order_id INT, customer_id INT, order_date STRING, "
    "total_amount DOUBLE, status STRING, channel STRING",
).withColumn("order_date", F.to_timestamp("order_date"))
updates = shipped.unionByName(new_order)
print("Update rows:", updates.count())

# 4. MERGE: updates the orders that already exist and inserts those that do not
delta_table = DeltaTable.forPath(spark, DELTA_PATH)
(
    delta_table.alias("t")
    .merge(updates.alias("u"), "t.order_id = u.order_id")
    .whenMatchedUpdate(set={"status": "u.status"})
    .whenNotMatchedInsertAll()
    .execute()
)

# 5. Table history
delta_table.history().select("version", "operation").orderBy("version").show()

# 6. Current state versus the previous version (time travel)
current = spark.read.format("delta").load(DELTA_PATH)
version_0 = spark.read.format("delta").option("versionAsOf", 0).load(DELTA_PATH)
print("Rows now:", current.count(), "| rows in version 0:", version_0.count())
print("Pending now:", current.where("status = 'pending'").count(),
      "| pending in version 0:", version_0.where("status = 'pending'").count())

spark.stop()

Step by step:

  • Block 1. The two .config(...) lines enable Delta in Spark, and configure_spark_with_delta_pip adds its Java components. This is configuration code that you copy as it stands.
  • Block 2. The only difference from a Parquet write is .format("delta"). The result is a folder of Parquet files plus the _delta_log subfolder. This is version 0.
  • Block 3. The nightly batch is simulated: the orders from 30 June that were still pending become shipped, and a new order, number 20,001, is added. createDataFrame builds a table from a list of rows and the description of its columns.
  • Block 4. This is the MERGE from before, written with the Python API: a match condition on order_id; if there is a match, status is updated; if not, the whole row is inserted.
  • Block 5. history() returns the contents of the transaction log in the form of a table.
  • Block 6. option("versionAsOf", 0) reads the table as it was in version 0.

Output from a real run (without the first-time download messages):

Update rows: 6
+-------+---------+
|version|operation|
+-------+---------+
|      0|    WRITE|
|      1|    MERGE|
+-------+---------+

Rows now: 20001 | rows in version 0: 20000
Pending now: 1007 | pending in version 0: 1011
  • The updates amounted to 6 rows: 5 status changes and 1 new order.
  • The table has gone from 20,000 to 20,001 rows. Pending orders drop from 1,011 to 1,007: five fewer because of those shipped, one more because of the new order.
  • Version 0 is still there, available to query. If the MERGE had been a mistake, restoring it would be all it took.

Now look at the folder with ls -A lake/silver/orders_delta: you will see _delta_log and two Parquet files. To change five rows, Delta has written a new file with all 20,001 rows and noted in the log that the old one is no longer valid. The old one stays on disk, and that is why time travel is possible. It has a cost: the space grows with every change until a clean-up operation (VACUUM) removes the files that are no longer needed, and with them the possibility of going back to those versions.

If you run the script more than once, each run adds versions to the history (a new write and a new MERGE); to start from scratch, delete the lake/silver/orders_delta folder.

Leave silver/orders (Parquet) just as it was: the coming lessons will carry on using it.

Lake, warehouse or lakehouse: how to choose

Aspect Data lake Data warehouse Lakehouse
Data types All Structured (and semi-structured) All
Storage format Open files Specific to the engine Open files + table format
Schema On read On write Enforced, with evolution
ACID transactions No Yes Yes
Updating and deleting rows Difficult Yes Yes (MERGE, UPDATE, DELETE)
Version history No Depends on the product Yes
SQL and reporting Limited Excellent Good or very good
Data science and ML Excellent Limited Excellent
Storage cost Very low Higher Very low
Operational complexity Medium; demands discipline Low if it is a managed service Medium
Engines that can read it Many Its own Many

Rough criteria:

  • Structured data only, moderate volume and use centred on reporting: a cloud data warehouse is the simplest option.
  • Varied, high-volume data, with machine learning as well as reporting: a lakehouse avoids duplicating data and systems.
  • A data lake without a table format makes little sense today for new projects, except as a bronze zone.

The boundaries are blurring: cloud data warehouses already read and write Iceberg or Delta tables, and lakehouse platforms offer ever faster SQL engines. The categories are for reasoning with, not for rigidly classifying products.

NovaMarket's decision

Irene opts for a lakehouse. The reasons: the clickstream (2.79 TB a year at source) is too voluminous to pay for at data warehouse prices; three of the four use cases (demand forecasting, recommendations, fraud) are machine learning ones and need the data in open files; and the team is small, so keeping two systems in sync would be a burden. The bronze zone keeps the original files; silver and gold become tables in an open table format, and the star schema lives in gold.

In the course's practical work we will carry on working with plain Parquet in ~/novamarket/lake/, which is enough for learning to process data and adds no dependencies.

Common Mistakes and Tips

  • Modelling the data warehouse like the source database. Copying the normalised tables forces many joins in every report. The dimensional model exists to avoid that.
  • Not defining the grain. Mixing order rows and line rows in one fact table leads to amounts being added up twice.
  • Confusing file format and table format. Delta, Iceberg and Hudi do not replace Parquet: they organise it.
  • Handling the files of a Delta table by hand. Copying or deleting Parquet files without going through the log leaves the table inconsistent. Every modification must be made through the format.
  • Forgetting the clean-up. Without VACUUM and without compacting the small files left by frequent writes, the table grows and becomes slow.
  • Believing that time travel is a backup. It depends on files that the clean-up removes and lives on the same storage as the table.
  • Installing delta-spark without checking compatibility. The errors caused by incompatible versions are cryptic (Java classes not found). Check first.
  • Tip: choose a single table format for the whole platform. Mixing them multiplies the complexity for no benefit.

Exercises

Exercise 1: OLTP or OLAP?

Classify each operation and say which NovaMarket system would handle it:

  1. Checking whether any units of product 142 are left before confirming a purchase.
  2. Calculating the average amount per order for each province in the first half of the year.
  3. Changing the delivery address of a pending order.
  4. Comparing returns by category between the website and the app.

Exercise 2: a query on the star

Add to star_schema.py a SQL query that shows, by customer province, the number of distinct orders and the total sales (excluding returns), limited to the 5 provinces with the highest sales. Which dimension do you need? What happens to the customers with no province?

Exercise 3: designing a star for the web events

Marc wants to analyse the conversion funnel with the same approach. Design on paper a star schema for web_events: state the grain, the measures, the dimensions and what you would do with the events from anonymous visitors.

Solutions

Exercise 1

  1. OLTP. Reading one row by key, in milliseconds: the shop's database.
  2. OLAP. An aggregation over six months of data: data warehouse or lakehouse.
  3. OLTP. Updating one row: the shop's database.
  4. OLAP. It aggregates and compares over the whole history: data warehouse or lakehouse.

Exercise 2

spark.sql("""
    SELECT c.province,
           COUNT(DISTINCT f.order_id)     AS orders,
           ROUND(SUM(f.line_amount), 2)   AS sales
    FROM fact_sales f
    JOIN dim_customer c ON f.customer_id = c.customer_id
    WHERE f.status <> 'returned'
    GROUP BY c.province
    ORDER BY sales DESC
    LIMIT 5
""").show()
+---------+------+----------+
| province|orders|     sales|
+---------+------+----------+
| Valencia|  4100|6905275.27|
|   Madrid|  3633|6145802.21|
|Barcelona|  2979|4932768.05|
| Alicante|  1446|2493423.82|
|  Sevilla|  1155|1934451.94|
+---------+------+----------+

You need dim_customer. COUNT(DISTINCT f.order_id) is required rather than COUNT(*) because the grain is the line: counting rows would give lines, not orders. The 20 customers with no province form a group of their own with a null province; if they sold enough, they would appear in the result as NULL. In a real data warehouse that null is replaced with an explicit value such as Unknown, so that the reports do not show gaps.

Common mistake: adding up the order's total_amount from a table with line grain. An order with three lines would have its amount added three times.

Exercise 3

A reasonable solution:

  • Grain: one row per web event.
  • Fact table fact_events: event_id, date_id, customer_id, product_id, session_id, event_type, device and event_time. It has no numeric measures of its own: the measure is the row count. These tables are called "factless fact tables" and are common for events.
  • Dimensions: dim_date, dim_customer and dim_product, the same ones as in sales. Sharing dimensions between stars lets you cross-reference events and sales using identical criteria. event_type and device, with three or four values, can stay in the fact table.
  • Anonymous visitors: instead of leaving customer_id null, a special row is added to dim_customer (for example, customer_id = -1, name Anonymous) and the events point to it. That way no join loses rows and the report shows "Anonymous" instead of a gap. The same would be done with product_id for searches.

Conclusion

A data warehouse is a database for analysis (OLAP), separate from the operational systems (OLTP), with schema-on-write, transactions and an MPP architecture, nowadays almost always bought in the cloud. Its data is organised with dimensional modelling: fact tables with the measures and dimension tables with the context, forming a star schema like NovaMarket's sales one (fact_sales, dim_date, dim_customer, dim_product). The data lake, for its part, lacks transactions and reliable updates, and maintaining both systems duplicates data and effort. The lakehouse unifies them through open table formats — Delta Lake, Iceberg, Hudi — which add a transaction log to the Parquet files, and with it ACID, MERGE, time travel and schema enforcement.

This lesson brings Module 2 to an end, and you can now say where every piece of NovaMarket's data lives. Orders, customers and products are born in the shop's relational database; events, on the website and the app. All of it comes together in the lakehouse, on object storage: in bronze, the original files in CSV and JSON; in silver, clean tables in Parquet, with the events partitioned by date; in gold, the star schema and the aggregated tables that Marc and the dashboards query. And the data the website needs instantly is served from NoSQL databases: carts and rankings in Redis, the catalogue in MongoDB, the history by customer in Cassandra. On your own machine you have the miniature version: ~/novamarket/lake/ with its three zones.

So far, however, you have used Spark as a black box: a few lines that read, cleaned and wrote without your knowing what was going on underneath. Storing the data is only half the problem; the other half is processing it when it does not fit on one machine. That is what Module 3, Big Data Processing, is about. We will start at the beginning, with the model that started it all and on which the file system that opened this module was built: MapReduce and Hadoop.

© Copyright 2026. All rights reserved