internalsGet Pro

Module 01 · Lesson 2 of 11Free

The data lifecycle: from source to decision

Level
Beginner
Topic
Data engineering fundamentals
Reading time
13 min

When you finish this page you can

  1. Name the five stages of the data engineering lifecycle and what happens to one record at each.
  2. Explain why rows that change after they are copied make a report go stale, and choose a way to load them.
  3. Decide what to keep at the storage stage so a number can be rebuilt when its definition changes.
  4. Trace a change made by the app team through every later stage to the report it breaks.
  1. Introduction to data engineering12 min
0:00 / 5:20
Show transcript

0:00 It’s Thursday. Daniel works in finance at Kartly, an online store in India. He checks Monday’s revenue in two places. Meera’s daily revenue table says 6.77 crore rupees. The order admin screen, which reads the live database, says 6.71 crore. Both use the same definition of revenue. So where did six lakh rupees go? Here’s the clue. The nightly load ran without errors on Tuesday. Nothing failed. So what changed between Tuesday and Thursday? To find out, we’ll follow one order from the customer’s tap to Daniel’s number. And we’ll ask what happens to data at each stage, and where it can go wrong. That’s the data lifecycle.

0:37 Follow one order. A customer places it on Monday evening. It costs 1,200 rupees. That order passes through five stages. Generate: the app creates the order. Store: the app’s database keeps it. Ingest: at one in the morning, the nightly load copies it out. Transform: a query turns rows into a revenue figure. Serve: Daniel’s report reads it. Notice that storage shows up twice. The app’s database stores the order first. Later, a second store built for analysis keeps a copy. Meera, the data engineer, owns every stage except one: the first. The app team owns that stage. That’s where the data starts, and most wrong numbers start a stage or two before anyone sees them.

1:13 Now the customer cancels. The app updates the order’s row. The status changes from placed to cancelled. The old value is gone, and nothing tells the pipeline. Meera’s load took its copy on Tuesday at one in the morning. Think of that copy as a photo. Anything that changes after the photo is not in it. That’s Daniel’s answer. About 500 Monday orders were cancelled on Tuesday and Wednesday. The live database knows. Meera’s table still holds the photo, so it still counts them. The revenue definition was fine. The copy was older than the source. Click events behave differently. A page view never changes once it’s recorded. The app only adds new ones. So loading yesterday’s clicks is complete. Loading yesterday’s orders is not. That difference decides how each kind of data must be loaded.

1:58 So how should the nightly load pick up orders that change later? Option one: load only yesterday’s orders. It’s small and fast, but every order is frozen at its first copy. Option two: copy the whole table every night. It’s always right, but it grows every day. After a year, each night reads about 22 million rows. Option three: copy only the orders that were created or changed since the last load. That’s called an incremental load. At Kartly, it reads about 36 megabytes a night. That’s roughly 120 times less than the full copy after a year. And it stays flat as history grows. Meera picks this one. It has a cost: an agreement with the app team. Every change must stamp the row with the time it changed. And orders are never deleted outright, because a deleted row leaves nothing to find. If rows were deleted, or changes were needed within minutes, Meera would read the database’s own log of changes instead. That’s called change data capture. Kartly moves to that later.

2:52 Now the same order arrives several times. Placed, on Tuesday’s load. Shipped, on Wednesday’s. Cancelled, on Thursday’s. What should the store keep? Meera could overwrite each order with its newest version. Then the store always matches the source. But there would be no history. And when a load goes wrong, nothing shows what actually arrived. So Meera keeps a raw table. Each night’s rows are added unchanged, with the date they were loaded. Nothing is ever edited. Every other table is built from it. The transform reads the newest version of each order, and the older ones stay for rebuilding history. The cost is space. Orders add about 36 megabytes a night. Click events add far more, about 3 gigabytes a day. Raw rows also hold customers’ personal details, and privacy laws limit how long Kartly may keep them.

3:38 Next, the transform. It has two jobs. First, pick the newest version of each order. Second, apply finance’s definition: orders placed that day, minus the cancelled ones. There’s a catch. Monday’s orders keep changing for days, so Monday’s revenue isn’t final on Tuesday. That’s called late-arriving data. So Meera rebuilds the last few days every night. Serving is where the table meets its readers. Daniel’s report. Analysts’ queries. Later, dashboards and models. What Meera serves is more than rows. It’s a promise. Ready by seven in the morning. One definition of revenue. And the most recent days marked as still changing. Stages are linked, so a change at the start reaches the end. Say the app team’s release on Wednesday spells cancelled with one L. The load copies the new rows without error. The transform filters on the old spelling, and no row has it any more. So every cancellation counts as revenue. Wednesday’s figure is about 43 lakh too high. Daniel sends it to leadership. No job failed. No alert fired. The fix has two parts. The transform checks that every status is one it knows, and stops the publish when a status is new to it. And the app team agrees to warn Meera before they change what rows contain. That agreement is called a data contract.

4:47 Let’s recap. One: data passes through five stages, and a wrong number often starts a stage or two before anyone sees it. Two: apps change rows in place, so a copy goes stale. Clicks only grow, so they load by day. Three: an incremental load catches changes, if the app stamps the row and never deletes. Four: keep every raw load unchanged, so history can be rebuilt. Five: serving is a promise of time and meaning, and a data contract protects it. Meera now owns four of the five stages. That’s a lot for one job title. Next, we’ll see how data teams split the work. See you in Data engineering roles.

Same definition, still two numbers

It’s Thursday. Daniel, who leads finance reporting at , compares two figures for Monday. Meera’s daily revenue table says ₹6.77 crore. Kartly’s order admin screen, which reads the live database, says ₹6.71 crore.

Kartly is an online store in India. It takes about 60,000 orders a day, and Meera, a data engineer, loads them each night from a PostgreSQL into an analytical store. Daniel reads the result at 07:00.

In the previous lesson, two teams disagreed because each defined revenue its own way. Meera fixed that with one definition in one . Both figures here use that definition. So where did ₹6 lakh go?

Check yourselfAnswer in your head first, then reveal
Both numbers count Monday’s orders that were not cancelled. The pipeline ran without errors on Tuesday at 01:00. What happened between Tuesday and Thursday?Show answerHide answer
About 500 Monday orders were cancelled on Tuesday and Wednesday. The app changed their status in the live database, but Meera’s table still holds the copy taken at 01:00 on Tuesday. Not a bug in the revenue definition: the copy is older than the source.

The 500 late cancellations and the ₹6.71 crore figure are this lesson’s scenario numbers: 500 × ₹1,200 = ₹6 lakh.

This lesson follows one order from the customer’s tap to Daniel’s number, and answers one question: what happens to data at each stage on its way to a decision, and where can it go wrong?

Five stages one order passes through

Joe Reis and Matt Housley call this path the 1. It has five stages: generate, store, ingest, transform and serve 2. Storage comes before ingestion in that list, and at Kartly data is stored at both ends: in the app’s database and in the analytical store. Follow one ₹1,200 order placed on Monday at 18:00.

One order’s path through the five stages. Storage appears twice: in the app’s database and in the analytical store.
Stage What happens to the order Who owns it The question at this stage
Generate The app writes a row, then updates its status as it ships or is cancelled The app team What does a row look like, and how does it change?
Ingest The nightly load copies it from the replica Meera Which rows do we copy, and when?
Store The copy lands in the analytical store Meera What do we keep, and for how long?
Transform SQL turns rows into one revenue figure Meera, with finance’s definition What does the number mean?
Serve The revenue table feeds Daniel’s report Meera, read by Daniel When is it ready, and can it still change?

The first row matters most. Meera owns every stage but one, and that one is where the data starts.

The app changes rows in place

When a customer cancels, the app runs an UPDATE on the order’s row. The status goes from placed to cancelled. The old value is gone from the table, and nothing tells the pipeline that a change happened.

The copy is a photo taken at 01:00. Every change after that reaches the source but not the copy.

Click events behave differently. A page view, once recorded, never changes; the app only adds new ones. At Kartly, the app writes each click event as a row in PostgreSQL too, so both arrive through the same replica. But loading “yesterday’s click events” is complete, while loading “yesterday’s orders” is not.

That difference decides how each table must be loaded. Data sources covers the other kinds of source Meera will meet: files, APIs and event streams.

Ingestion decides what the copy can know

Meera’s load today copies orders placed yesterday. That made sense for clicks and broke for orders.

How should the nightly load pick up orders that change after the day they were placed?

Keep loading only the orders placed yesterday.

About 60,000 rows and 12 MB a night. Fast and small, but each order is frozen at its first copy. Monday’s revenue stays ₹6 lakh too high forever.

Copy the whole orders table every night.

Always matches the source. But the table grows by about 60,000 rows a day, so after a year each night reads about 22 million rows from the replica, and long reads there can be cancelled.

Read the database’s own log of changes.

Catches every change, including deletes, within seconds. It needs new infrastructure to run and watch, which Kartly doesn’t need at this size.

Why this choice

The problem is that the source holds only the latest value of each row. Any load that copies a row once and never again misses later changes. The three working options differ in how they find the changed rows.

A full copy is the simplest: no column to trust, no logic to get wrong. Its cost grows with the table’s whole history, not with the day’s activity. The numbers below are estimates for this scenario.

Full copy after one year

60,000 orders × 365 days ≈ 22 million rows × 200 bytes ≈ 4.4 GB a night

And it keeps growing every year, though a day’s activity stays the same.

Rows created or changed in one day

60,000 new + 60,000 shipped + 60,000 delivered ≈ 180,000 rows at most

Each order changes status about twice after it is placed. Some of these overlap, so this is an upper bound.

Size of the changed rows

180,000 rows × 200 bytes ≈ 36 MB a night

About 120 times less than the full copy after a year, and it stays flat as history grows.

An is a load that reads only rows created or changed since the last one. Meera picks it. The cost is an agreement with the app team: every change must set updated_at, and orders are never deleted outright. Incremental loads with watermarks covers how to track “since the last load” safely.

The choice changes in two cases. If the orders table were small, the full copy would win on simplicity. If the app deleted rows, or the business needed changes within minutes, Meera would read the database’s change log instead, which is , covered in Change data capture. Kartly moves to that at a later stage of growth.

Storage keeps every load as it arrived

An incremental load brings the same order several times: placed on Tuesday’s load, shipped on Wednesday’s, cancelled on Thursday’s. Meera has to decide what the store keeps.

She could overwrite each order with its newest version. The store would then always look like the source. But when finance later decides that revenue should also subtract refunds, there is no history to rebuild from. And when a load goes wrong, nothing shows what actually arrived.

So Meera keeps a raw table. Each night’s rows are appended unchanged, with the date they were loaded, and never edited. Every later table is built from it.

The raw table keeps every version of an order. Transforms read the newest version, and the older ones stay for rebuilding history.

The cost is space. Orders add about 36 MB a night, about 13 GB a year (an estimate). Click events add about 3 GB a day, so they dominate. Raw rows also hold customers’ personal details, and India’s and the EU’s privacy laws limit how long Kartly may keep them. Retention and deletion requests covers how long to keep raw data and how to delete from it.

Transformation and serving make a promise

The transform step now has two jobs. It picks the newest version of each order from the raw table. Then it applies finance’s definition: orders placed that day, minus cancelled ones.

There is a catch. Monday’s orders keep changing for days, so Monday’s revenue isn’t final on Tuesday. This is . Meera’s transform rebuilds the last few days each night, not only yesterday. Late and out-of-order records in batch pipelines covers how far back to go.

Serving is where the table meets its readers: Daniel’s report, analysts’ queries, and later dashboards and models. What Meera serves is more than rows. It is a promise: ready by 07:00, one definition of revenue, and the most recent days marked as still changing.

Stages are linked, so a change at the start reaches the end.

A spelling change in the app inflates revenue

  1. On Wednesday, the app team’s release changes the status value cancelled to canceled.
  2. The nightly load copies the new rows without error. Ingest doesn’t check values.
  3. The transform excludes orders where status is cancelled. No row has that value any more.
  4. Every cancellation since the release counts as revenue. Wednesday’s figure comes out about ₹43 lakh too high: 3,600 orders × ₹1,200.
  5. Daniel sends it to leadership. No job failed, and no alert fired.

The fix has two parts. The transform checks that every status is one it knows, and stops the publish if one isn’t. And the app team agrees to warn Meera before changing what rows contain. That agreement is a , covered in Data contracts.

The work under every stage

Some work belongs to no single stage. Reis lists six of these “undercurrents”: security, data management, DataOps, data architecture, orchestration and software engineering 2. At Kartly they already show up. Running the load at 01:00 and the transform after it is orchestration. The status check is data management. Deciding who may read raw rows with personal details is security.

You don’t need to learn them now. Notice that each stage’s question has a part that spans the whole pipeline.

Try it yourself

See one day’s revenue change between two loads. You need Python 3.11 or later and DuckDB:

Bash
pip install duckdb==2.0.0

Save this as lifecycle.py and run python lifecycle.py. duckdb.sql runs each query on an in-memory database 4, so nothing is saved.

Python
import duckdb

# Two nightly loads of the same three Monday orders (made-up data).
duckdb.sql("""
    CREATE TABLE raw_orders AS
    SELECT * FROM (VALUES
        (DATE '2026-11-10', 1001, DATE '2026-11-09', 1200, 'placed'),
        (DATE '2026-11-10', 1002, DATE '2026-11-09',  800, 'cancelled'),
        (DATE '2026-11-10', 1003, DATE '2026-11-09', 2500, 'shipped'),
        (DATE '2026-11-12', 1001, DATE '2026-11-09', 1200, 'cancelled'),
        (DATE '2026-11-12', 1002, DATE '2026-11-09',  800, 'cancelled'),
        (DATE '2026-11-12', 1003, DATE '2026-11-09', 2500, 'delivered')
    ) AS t(loaded_on, order_id, ordered_on, amount_inr, status)
""")

# Monday's revenue, as each load saw it.
duckdb.sql("""
    SELECT
        loaded_on,
        sum(amount_inr) FILTER (WHERE status <> 'cancelled') AS revenue_inr
    FROM raw_orders
    WHERE ordered_on = DATE '2026-11-09'
    GROUP BY loaded_on
    ORDER BY loaded_on
""").show()

FILTER limits which rows one aggregate adds up 3. The output looks something like this:

Text
┌────────────┬─────────────┐
│ loaded_on  │ revenue_inr │
├────────────┼─────────────┤
│ 2026-11-10 │        3700 │
│ 2026-11-12 │        2500 │
└────────────┴─────────────┘

Monday’s revenue dropped by ₹1,200 between the loads: order 1001 was cancelled after the first one. Because the raw table kept both loads, you can see exactly why. Now change one 'cancelled' in the second load to 'canceled' and predict the new total before you run it.

Where this shows up

Meera now owns four of the five stages, plus the work under them. That is a lot for one title, and the next lesson looks at how data teams split it.

Common mistakes

Loading changing rows by the day they were created

Orders, payments and accounts change after they are created. Load them by when they last changed, or the copy freezes each row at its first version.

Keeping only the cleaned table

If the store holds only transformed data, a new definition can’t be applied to past days, and a bad load leaves no trace. Keep raw loads unchanged, for as long as the retention rules allow.

Check your understanding

Check yourselfAnswer in your head first, then reveal
Product wants yesterday’s count of searches for “phone”. Does the click-events load need the same updated_at approach as orders?Show answerHide answer
No. Click events are never changed after they are written, so copying yesterday’s events is complete. Only data the app updates in place, like orders, needs to be reloaded when it changes.
Check yourselfAnswer in your head first, then reveal
The app team starts deleting test orders outright instead of marking them. What does Meera’s incremental load miss?Show answerHide answer
The deletes. A deleted row has no updated_at to find, so the copy keeps the order forever. She needs the app to mark rows instead, or to read the database’s change log, which records deletes.
Check yourselfAnswer in your head first, then reveal
Finance decides revenue should also subtract refunds, starting with last quarter. What does Meera need to rebuild it?Show answerHide answer
The raw loads, plus refund data. With every load kept unchanged, she reruns the transform with the new definition over past days. If she had kept only the old revenue table, last quarter couldn’t be rebuilt.
Check yourselfAnswer in your head first, then reveal
Daniel asks why Monday’s figure moved on Thursday. Which stage do you check first?Show answerHide answer
Generate: whether Monday’s orders changed in the source after Tuesday’s load. Late cancellations are normal, so a moving recent figure is expected. Not the transform, unless the source rows show no changes.

Summary

  1. Data passes through five stages, generate, ingest, store, transform and serve, and a wrong number often starts a stage or two before anyone sees it.
  2. Apps update rows in place, so a copy taken once goes stale; click events only grow, so they can be loaded by day.
  3. At Kartly’s size, an incremental load by updated_at catches changes for about 36 MB a night, if the app sets the column and never deletes rows.
  4. Keep every raw load unchanged, so history can be rebuilt when a definition changes or a load goes wrong.
  5. Serving is a promise of time and meaning, and a change at the app can break it unless a check and an agreement guard it.

Report a mistake

Tell us what’s wrong in this lesson and we’ll fix it.