Data models and processing
Follow raw records from bronze to silver and gold, then choose a schema and change-history strategy for the business question.
Queries and query languages
A query is a request to read data (a read) or to change it with INSERT, UPDATE, DELETE (a write). Queries can also run maintenance, for example ANALYZE TABLE ... COMPUTE STATISTICS or OPTIMIZE. The result is usually tabular but can be JSON or XML. A query language is the format of the request: SQL is the main one; GraphQL and vendor languages exist. In Databricks you submit queries from the SQL editor, notebooks, the CLI, JDBC/ODBC clients or the SQL Statement Execution API.
Pivot tables
A pivot table summarizes a larger table by rotating row values into columns and aggregating them (sum, average, min, max) by dimensions such as year, month or day. Excel popularized it; in Databricks SQL you write it with the PIVOT clause (SQL commands and logic).
Batch, streaming, and incremental
| Pattern | Meaning | Databricks tools |
|---|---|---|
| Batch | Process a bounded set of data at once, usually on a schedule | spark.read, SQL, scheduled Lakeflow Jobs |
| Streaming | Process an unbounded, continuously arriving data set | Structured Streaming, Auto Loader, streaming tables |
| Incremental | Each run processes only data that is new since the last run | Auto Loader, COPY INTO, streaming with availableNow trigger, materialized views with incremental refresh |
Incremental batch is the most common real pattern: a job runs every hour, picks up only new files, then stops. You get streaming-style bookkeeping (checkpoints) at batch cost.
Batch vs streaming trade-offs
| Batch | Streaming | |
|---|---|---|
| When it runs | On a schedule (for example daily at 1 p.m.) or on demand | Continuously, as each record arrives |
| Latency | Not real time; results after the batch completes | Near real time |
| Cost | Generally cheaper; compute runs only during the batch | Generally more expensive; compute stays on |
| Best for | Very large processing workloads, reports | Real-time analytics, alerting, live dashboards |
Producers, consumers and streams
In a streaming system, producers write events to a stream (Kafka topic, Kinesis stream, Event Hubs) and consumers read them. The stream keeps events for a retention period, so several consumers can read the same data independently. The Azure path in the video (Event Hubs to Stream Analytics to Cosmos DB to Power BI) maps in Databricks to: Kafka or Event Hubs, then Structured Streaming or a streaming table, then Delta tables, then AI/BI dashboards.
ETL vs ELT
- ETL (Extract, Transform, Load): transform before loading into the target. Classic warehouse pattern.
- ELT (Extract, Load, Transform): land raw data first, then transform inside the platform. This is the lakehouse pattern, because storage is cheap and raw data is kept for replay.
The medallion architecture
| Layer | Contents | Typical operations |
|---|---|---|
| Bronze (raw) | Data as ingested, append-only, often with metadata such as file name and ingestion time | Auto Loader, COPY INTO, Lakeflow Connect |
| Silver (cleaned) | Validated, deduplicated, typed, joined, conformed | Clean nulls, cast types, dedupe, quality checks, MERGE |
| Gold (curated) | Business-level aggregates and models for BI and ML | Aggregations, star schemas, materialized views |
The medallion architecture is also called the multi-hop architecture. Each layer is a set of persisted tables: the same data is stored three times at three levels of refinement, not just passed through a pipeline. Bronze keeps the raw history so you can archive, reprocess and validate (no schema needed at landing); silver defines, enforces and evolves the schema and gives the most flexibility; gold is the most refined, built for specific business use cases (KPIs, facts and dimensions for BI).
Know which layer an operation belongs to. "Read bronze, clean nulls, standardize types, write silver" is an explicit exam objective. Gold objects for BI (views, materialized views, streaming tables, tables) are another (Tables and views).
"Multi-hop" and "medallion" mean the same thing. If a question asks why you keep bronze after building silver, the answer is reprocessing: you can rebuild silver and gold from the raw data when logic changes or a bug is found.
Data modeling
A data model describes which objects hold the data and how they relate. Start with the classic relational building blocks, then the modeling styles used for analytics.
Relational objects and their Databricks equivalents
| Classic RDBMS object | Meaning | In Databricks |
|---|---|---|
| Table | Rows and columns | Delta table |
| View | Saved query, a virtual table with no stored data. (The video says "stored in memory"; more precisely, it is recomputed each time it is read.) | CREATE VIEW, temp views (Tables and views) |
| Materialized view | Query result stored on disk | CREATE MATERIALIZED VIEW (Tables and views) |
| Index | Sorted redundant copy of some columns, usually a B-tree (balanced tree, not a binary tree), for faster reads at the cost of storage. Example: CREATE INDEX idx_phone ON addresses (phone_number); in PostgreSQL. | No B-tree indexes. Delta uses file-level min/max statistics (data skipping), Z-ordering and liquid clustering (Delta Lake). |
| Constraint | Rule checked on writes | NOT NULL and CHECK enforced; PRIMARY KEY, FOREIGN KEY informational only (Data integrity) |
| Trigger | Function fired on a table event, for example generating a UUID after an insert | No DML triggers. Use identity columns (GENERATED ALWAYS AS IDENTITY), uuid() in the write, or job triggers on file arrival or table update (Lakeflow Jobs and monitoring). |
| Primary / foreign key | PK uniquely identifies a row (often id); FK holds another table's PK (often othertable_id) | Declared, not enforced |
Relationship types
- One-to-one: a country has one capital.
- One-to-many: a store has many customers; a book has many pages.
- Many-to-many: a book has many authors and an author writes many books.
- Many-to-many through a join (junction) table: students and classes linked through an
enrollmentstable that holds both foreign keys. This is how many-to-many is physically stored in a relational model.
Normalization
Normalization splits data into many tables to remove redundancy (1NF, 2NF, 3NF). It suits OLTP. Analytics prefers denormalized models to avoid many joins.
Dimensional modeling (Kimball)
- Fact table: measurable events (sales, clicks) with foreign keys and numeric measures. Long and narrow.
- Dimension table: descriptive context (customer, product, date). Short and wide.
- Star schema: one fact table surrounded by denormalized dimensions. Snowflake schema: dimensions further normalized into sub-dimensions.
Slowly changing dimensions (SCD)
- SCD Type 1: overwrite the old value. No history.
- SCD Type 2: keep history by adding a new row with validity columns such as
__START_AT/__END_ATor a current flag.
Declarative Pipelines implement both with AUTO CDC ... STORED AS SCD TYPE 1|2 (Lakeflow Declarative Pipelines).
Data Vault and One Big Table
Data Vault (hubs, links, satellites) is used in some silver layers. "One big table" is a fully denormalized gold table. You only need to recognize the terms.
Non-relational (NoSQL) data models
| Model | Structure | Good for |
|---|---|---|
| Key-value | Each value retrieved by a unique key | Simple, very fast lookups at scale |
| Document | JSON-like documents (a document store is a key-value store whose values are documents) | Flexible, nested records |
| Wide-column / columnar | Table-like, stored by column families | Huge sparse data sets |
| Graph | Nodes and edges | Data where relationships matter most |
Some services are multi-model, for example Azure Cosmos DB and Amazon DynamoDB (key-value and document). Note: the video calls column stores "basically NoSQL". Today columnar formats such as Parquet and Delta power mainstream SQL analytics, including Databricks SQL.
Change data capture (CDC)
CDC means capturing inserts, updates and deletes from a source system, typically as a feed of change rows with an operation type and a sequence or timestamp. You apply them to a target with MERGE INTO or AUTO CDC. Delta tables can also produce a change feed (Change Data Feed, Delta Lake).
Model a customer move
A customer orders in Paris, moves to Lyon, and orders again. Design a dimension that lets a report show the city at the time of each sale.
Check your reasoning
Keep two dimension rows with distinct surrogate keys, the same customer business key, and non-overlapping validity intervals. Each sale joins to the applicable version.
Product reference
Medallion lakehouse architecture in the Databricks documentation
Data models and processing quiz
Answer 8 questions. Check each answer for an explanation.