New to Claude Skills? Learn how to install them →

posthog on GitHub

Modeling Dimension Tables

Free

Create reusable dimension tables for star schemas.

by posthog37.6k stars on posthog/posthog
5 views
Updated Aug 11, 2026
Get this skill

Free · Opens the source repo

What Modeling Dimension Tables does

The Modeling Dimension Tables skill provides a structured approach to building reusable dimension and lookup tables essential for star schema designs. This skill is particularly useful for developers and data analysts working with PostHog data-warehouse views or external dbt projects. It simplifies the process of modeling dimension tables, such as country, region, timezone, and product plans, allowing users to enrich their event data without the overhead of repetitive JOIN operations.

By following a three-step process—sourcing, shaping, and attaching—users can efficiently create dimension tables. The sourcing step allows for various methods, including uploading CSV files, syncing from existing databases, or deriving data from events. The shaping step involves creating a clean, aliased view with one row per entity, ensuring data integrity and ease of use. Finally, the attaching step integrates these dimensions with fact tables, enabling seamless querying and reporting.

This skill is designed for teams looking to enhance their data models by incorporating descriptive attributes that improve analytics and reporting capabilities. It also emphasizes best practices, such as ensuring unique keys in dimensions, using stable naming conventions, and materializing static dimensions on a slow schedule, which can significantly improve query performance.

For those already using PostHog, the skill provides built-in support for currency conversions through the convertCurrency() function, eliminating the need for custom currency tables unless specific requirements dictate otherwise. Overall, this skill streamlines the modeling process and promotes the reuse of dimension tables across various analytical models, making it a valuable addition for data-centric teams.

When to use it

Use this skill when you need to create reusable dimension tables for analytics and reporting in a data warehouse environment.

When not to use it

This skill may not be suitable if you require highly customized dimension tables that do not fit the standard star schema approach.

What you can build with it

Creating Country Dimension Table

Use the skill to build a dimension table for countries, sourcing data from existing databases or CSV uploads.

Integrating Timezone Data

Model and attach a timezone dimension to your fact tables to enhance time-based analytics.

Building Product Plan Dimensions

Create a reusable dimension for product plans, ensuring consistent usage across various revenue and usage metrics.

How to install Modeling Dimension Tables

View source

1. Install with the skills CLI

npx skills add posthog/posthog/modeling-dimension-tables --agent claude-code

2. Or install it manually

Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.

Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs

Inside SKILL.md

Written by posthog

Modeling dimension tables (star schema)

Dimensions are the descriptive tables (dim_country, dim_plan, dim_date) that fact tables join to for slicing. This skill builds them once, cleanly, so every other model reuses them instead of re-deriving lookups. Read modeling-warehouse-foundations first (joins + convertCurrency() live there). Catalog of common dimensions: references/dimension-catalog.md; recipes in references/posthog/ and references/dbt/.

Star schema in one screen

Facts (events, charges, revenue items) are long, keyed, and additive. Dimensions are short, one row per entity, descriptive. You model a dimension in three moves:

  1. Source it — where does the dimension data come from?
    • Upload / seed a lookup (country→region, plan→tier) as a CSV (warehouse source or dbt seed).
    • Sync it from a system of record (your app DB, Stripe products) as a warehouse source.
    • Derive it from events (distinct countries seen, a plan property observed per person).
  2. Shape it — an aliased SELECT with clean column names, one row per entity (dedupe hard). Save as a view; materialize it on a slow sync_frequency (7day/30day) since dimensions change rarely and are read constantly.
  3. Attach it — a saved join (dimension → a fact table) or person join (dimension → persons) so its columns appear as native fields in any query, filter, or breakdown. See foundations joins-and-dimensions.md.

Currency is already a managed dimension — don't build it

PostHog ships exchange rates behind convertCurrency(from, to, amount, timestamp?) (Open Exchange Rates, historical-rate-correct). Use it directly for any money conversion. Only build a currency dimension yourself in dbt (which has no equivalent), or if you need a rate provider PostHog doesn't offer.

Rules before you model

  1. One row per entity, unique key. A dimension with duplicate keys silently fan-outs every fact it joins. Test uniqueness (PostHog: verify in the shaping query; dbt: unique + not_null).
  2. Alias to clean, stable namescountry_code, region, plan_tier. These names become the join surface everything else depends on.
  3. Materialize static dimensions on a slow schedule; don't leave a constantly-read lookup virtual.
  4. Register and certify. Annotate the dimension and, if it's load-bearing, certify it in the catalog (foundations governance.md) so other models discover it and don't build a rival copy.
  5. Prefer built-in currency (convertCurrency) over a hand-rolled FX table on PostHog.

Build it

PostHog: shape an aliased dimension view, then materialize + join. Recipes: references/posthog/dim_country.sql (derive + enrich from events), dim_plan.sql (lookup/upload pattern).

dbt: conformed dim_* models with unique/not_null/relationships tests, plus a generated dim_date. Recipes: references/dbt/.

File map

FileRead when
references/dimension-catalog.mdCommon dimensions, how to source each, and the natural key.
references/posthog/HogQL aliased-dimension view recipes.
references/dbt/dbt dim_date / dim_country + schema.yml tests.

Companions

modeling-warehouse-foundations (joins + currency), setting-up-a-data-warehouse-source / suggesting-data-imports (sync/upload the source data), and the models that consume these dimensions: modeling-revenue-metrics, modeling-conversion-metrics, modeling-activation-metrics, modeling-product-usage-metrics.

Frequently asked questions about Modeling Dimension Tables

Similar skills