Cert EspressoLearn. Practise. Find your flow.

A LITTLE FOCUS.
A BIG NEXT STEP.

Your pace. Your space.
Databricks · Databricks Data Engineer Professional

Table layout, dimensional models, and metric views

Databricks Data Engineer Professional · Lesson 21 of 21 · 2:45:56

YouTube loads only after you press play. This chapter opens at its timestamp in the full course. Watch on YouTube ↗

Learning with these videos? Subscribe for new courses and exam-style questions.

In this lesson

Prepare for the Databricks Certified Data Engineer Professional exam. In this lesson: table layout, dimensional models and the star schema, materialized views, and metric views. Includes three original practice questions.

Study notes

The text of this lesson, to read at your own pace. Information as of November 2026.

Growing pains

At Quayside Eats, the orders table keeps growing, and its queries slow down, while dashboards compute the average order value in five different ways. The team needs a layout that scales, and one definition of each business measure. This lesson covers table layout, dimensional models, and materialized views and metric views.

Table layout

Most tables with less than one hundred terabytes do not need partitioning: below one terabyte, do not partition, and from one to one hundred terabytes, choose liquid clustering instead. On larger tables, partition only on a coarse column that matches the grain of the data and of the queries, like the event date, so that each partition stays large. Choose clustering keys from the access patterns: the columns most often used in filters and joins, like the restaurant ID that joins orders to restaurants. Small files slow every read, so keep file sizes balanced with compaction: optimize combines small files, and auto compaction and optimized writes reduce them as data is written. Databricks recommends autotuning, which sets the target file size from the size of the table, and a scheduled optimize for tables larger than one terabyte. Managed Iceberg tables follow the same advice, with liquid clustering too.

Dimensional models

A star schema puts a fact table in the center, with one row per event, like an order line, its keys, and numeric measures, like the amount. Dimension tables around it describe the context, with one row per entity, like a restaurant, a customer, or a date, and join to the facts through their keys. Choose the grain of the fact table first, like one row per order line, since every measure and every dimension depends on it. When natural keys are not stable, use surrogate keys, generated by an identity column, rather than a hash, which clusters poorly. The star schema is denormalized for fast reads, and it usually forms the gold layer.

Materialized and metric views

Materialized views precompute aggregations, like daily sales per restaurant, and store the results, so dashboards read them quickly. Their refresh is often incremental: Databricks processes only the changed data when it can, to keep the cost of each refresh low. Metric views, in Unity Catalog, define each business measure once, separate from the dimensions that group and filter it. A standard view locks in its aggregations and groupings, while a metric view lets users group by any available dimension, and the engine computes the measure correctly, even for ratios like revenue per distinct customer. Metric views are written in YAML, or in SQL with create view, with metrics, and they work in the SQL editor, notebooks, dashboards, Genie, and alerts.

Recap

Let's recap. Below one terabyte, do not partition, and up to one hundred terabytes, choose liquid clustering, with keys taken from the filters and joins. Keep file sizes balanced with compaction, autotuning, and a scheduled optimize on large tables. A star schema has a fact table at the chosen grain, and dimension tables joined by their keys. Materialized views precompute aggregations, often with incremental refresh. And metric views define each measure once, for any dimension.

Quick checks for this lesson

The 3 questions of this lesson, as plain text. The button above runs them with shuffled choices and the reason behind every choice.

  1. Most queries on the orders fact table filter on the order date, and join to the restaurants dimension on the restaurant ID. Which clustering keys fit?

    • order_id, which is unique
    • order_date and restaurant_id
    • customer_email
    • A hash of all the columns
    Show the answer

    order_date and restaurant_id

    Clustering on the columns used in filters and joins lets queries skip the files they do not need. “order_id, which is unique” is unique for each row, and no query here filters on it. “customer_email” is not used by these queries, and holds personal data. And “A hash of all the columns” would scatter related rows, and help no filter.

  2. Quayside Eats stores each order with the restaurant name, city, and cuisine repeated on every row, and renaming a restaurant means rewriting millions of rows. What model fixes this?

    • Partition the orders by restaurant name
    • A wider orders table, with more columns
    • A restaurants dimension, joined by a key
    • A materialized view of the orders
    Show the answer

    A restaurants dimension, joined by a key

    The restaurant details are stored once in a dimension table, and the facts keep only the key, so a rename touches one row. “Partition the orders by restaurant name” would split the table into many partitions, and still repeat the details. “A wider orders table, with more columns” would repeat even more details on every row. And “A materialized view of the orders” would precompute results, and still copy the details from the orders.

  3. A dashboard runs the same heavy aggregation of daily sales per restaurant every few minutes, over the full orders table. The results only change when new orders arrive. What should the data engineer create?

    • A materialized view of daily sales per restaurant
    • A standard view with the same query
    • A larger SQL warehouse for the dashboard
    • A temporary view in each session
    Show the answer

    A materialized view of daily sales per restaurant

    A materialized view stores the aggregated results, and refreshes them, often incrementally, so the dashboard reads them quickly. “A standard view with the same query” would run the same heavy query at every read. “A larger SQL warehouse for the dashboard” would make the same work faster, at a higher cost, without avoiding it. And “A temporary view in each session” would exist only for one session, and also compute at every read.