← Back to Data Engineering Foundations track
Reference

Data Engineering Foundations Cheat Sheet

The four opening lessons on one page: what the job is, the SQL a pipeline needs, PostgreSQL, and Python for moving data.

The job
What you build
source → pipeline → warehouse → people
# you own the path, not the chart
Batch vs streaming
batch:     a file or table, on a schedule
streaming: an event, as it happens
# start with batch unless the decision cannot wait
Medallion
bronze  raw, as landed
silver  cleaned, typed, deduped
gold    shaped for a question
SQL a pipeline uses
Orphan rows
SELECT o.order_id
FROM orders o
LEFT JOIN customers c
  ON o.customer_id = c.customer_id
WHERE c.customer_id IS NULL;
Keep the latest row
SELECT * FROM (
  SELECT *, ROW_NUMBER() OVER (
    PARTITION BY id ORDER BY updated_at DESC) AS rn
  FROM src) t
WHERE rn = 1;
Aggregate before you join
SELECT c.city, s.total
FROM customers c
JOIN (
  SELECT customer_id, SUM(amount) AS total
  FROM orders GROUP BY customer_id
) s ON s.customer_id = c.customer_id;
PostgreSQL
Table
CREATE TABLE events (
  id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
  user_id bigint NOT NULL,
  happened_at timestamptz NOT NULL DEFAULT now()
);
Load a file
\copy events (user_id, happened_at)
FROM 'events.csv' CSV HEADER;
Index the filter
CREATE INDEX events_user_time
ON events (user_id, happened_at DESC);
Python for data
Read and write
import csv
with open('in.csv') as src, open('out.csv', 'w') as dst:
    rows = csv.DictReader(src)
    writer = csv.DictWriter(dst, fieldnames=rows.fieldnames)
    writer.writeheader()
    writer.writerows(row for row in rows if row['id'])
Fail on a bad row
try:
    amount = int(row['amount'])
except ValueError:
    reject(row)
    continue
Idempotent key
# run the job twice, land the row once
INSERT INTO events (id, payload)
VALUES (%s, %s)
ON CONFLICT (id) DO NOTHING;

Projects to build

The fastest way to make this stick. Build one, then put it in your portfolio.

Beginner

One-table quality check

Load a CSV of orders into PostgreSQL and write three queries: null keys, duplicate ids, and amounts that are not numbers.

PostgreSQLCOPYdata quality
Beginner

Bronze to silver

Land a raw CSV as bronze, then a SQL view or table that dedupes on id and keeps the latest updated_at as silver.

SQLROW_NUMBERmedallion
Intermediate

Orphan report

Two tables, orders and customers. A Python script loads both and prints every order whose customer_id has no match.

LEFT JOINcsvPython
Intermediate

Daily batch

A script that reads yesterday’s file only, upserts into PostgreSQL, and writes a one-line log of rows in, rows rejected, rows written.

idempotencyloggingupsert
Advanced

Tiny warehouse

Bronze files by date, a silver table, and one gold query a teammate could paste into a dashboard: revenue by day and city.

medallionaggregationschema