01-grain-definition

Define fact table grain patterns for Gold layer data warehouse design.

5|6|Updated Jan 26, 2026
One-click install
npx skills add https://github.com/databricks-solutions/vibe-coding-workshop-template --skill 01-grain-definition
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: 01-grain-definition
Source: https://github.com/databricks-solutions/vibe-coding-workshop-template/tree/main/data_product_accelerator/skills/gold/design-workers/01-grain-definition
Command: npx skills add https://github.com/databricks-solutions/vibe-coding-workshop-template --skill 01-grain-definition

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill prevents costly data warehouse table rewrites by ensuring fact table grain is unambiguously defined during the Gold layer design phase, catching ambiguities before implementation.

Core Features & Use Cases

  • Grain Definition: Provides patterns and decision trees for identifying transaction, aggregated, and snapshot fact table grains.
  • YAML Documentation: Guides users on how to explicitly document grain type and primary keys in YAML schemas.
  • Use Case: When designing a new fact table for sales transactions, this skill helps determine if it should be transaction-level (one row per sale) or aggregated (e.g., daily sales per product), ensuring the correct primary key and merge logic are applied from the start.

Quick Start

Use the 01-grain-definition skill to document the grain for a new fact table by providing its primary key columns and intended measures.

Frequently Asked Questions about 01-grain-definition

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I define fact table grain for a data warehouse model?

Fact table grain defines the level of detail stored in a data warehouse table. You define it by identifying whether the table records transaction-level, aggregated, or snapshot data, ensuring unambiguous primary keys and measures from the start.

What is the difference between transaction, aggregated, and snapshot grain in dimensional modeling?

Transaction grain records one row per business event, aggregated grain groups measures to a specific level like daily sales per product, and snapshot grain captures the state of measures at a specific point in time.

How do I document fact table grain and primary keys in YAML schemas?

Document fact table grain in YAML schemas by explicitly declaring the grain type and listing the primary key columns. This enforces unambiguous implementation and prevents merge logic errors during Gold layer design.

Why does fact table grain ambiguity lead to data warehouse rewrites?

Grain ambiguity causes data warehouse rewrites because it leads to incorrect primary keys and merge logic. When fact table grain is not explicitly defined during the Gold layer design phase, measures are aggregated or joined incorrectly.

When do I need to define grain for Gold layer fact tables?

You need to define grain for Gold layer fact tables during the design phase before implementation. Defining grain early prevents costly rewrites by ensuring the correct primary keys and merge logic are applied from the start.