01-grain-definition

Define fact table grain types and document primary keys in YAML schemas.

1|Updated Jan 22, 2026
One-click install
npx skills add https://github.com/prashsub/vibe_coding_lakehouse_starter_repo --skill 01-grain-definition-prashsub
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: 01-grain-definition
Source: https://github.com/prashsub/vibe_coding_lakehouse_starter_repo/tree/main/data_product_accelerator/skills/gold/design-workers/01-grain-definition
Command: npx skills add https://github.com/prashsub/vibe_coding_lakehouse_starter_repo --skill 01-grain-definition-prashsub

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 ambiguity is resolved during the design phase, before implementation.

Core Features & Use Cases

  • Grain Definition: Clearly defines and documents the grain (level of detail) for fact tables.
  • Pattern Guidance: Provides patterns for transaction, aggregated, and snapshot fact tables.
  • YAML Documentation: Enforces explicit documentation of grain and primary key in YAML schemas.
  • Use Case: When designing a new fact_sales table, use this Skill to determine if it should store individual sales transactions or daily aggregated sales per product, documenting this decision clearly in the table's YAML schema.

Quick Start

Use the 01-grain-definition skill to document the grain for a new fact table schema, ensuring the primary key and grain type are explicitly defined.

Frequently Asked Questions about 01-grain-definition

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

FAQPage Schema
What is fact table grain in dimensional modeling, and when do I need to define it?

Fact table grain defines the exact level of detail stored in a data warehouse table. You need to define grain during the Gold layer design phase to prevent ambiguous data models and costly table rewrites.

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

To document fact table grain in YAML schemas, explicitly define the primary key structure and grain type, such as transaction or aggregated, ensuring unambiguous fact table design before implementation.

What are the different fact table grain patterns for data warehouse design?

Common fact table grain patterns include transaction, aggregated, and snapshot fact tables. Selecting the correct pattern uses a PK-grain decision tree to clarify the level of detail and primary key structure.

How do I decide between a transaction grain and an aggregated grain for a fact table?

To decide between transaction and aggregated fact table grain, apply a PK-grain decision tree during Gold layer design to determine if individual transactions or daily aggregated summaries best fit the schema.

Why does ambiguous fact table grain cause data warehouse table rewrites?

Ambiguous fact table grain causes data warehouse rewrites because the primary key and level of detail are unclear, leading to incorrect aggregations and requiring costly schema restructuring after implementation.

Do I need a specific framework to define dimensional modeling grain, or can I apply it to any data warehouse?

You can apply dimensional modeling grain definition to any data warehouse. It provides pattern guidance for transaction and snapshot fact tables and enforces explicit documentation in standard YAML schemas.