Skip to main content

Data Warehouse Schema Design

Design a data warehouse schema with fact and dimension tables, slowly changing dimensions, and query-optimized partitioning strategies.

Fill in the placeholders

Edit the values, then copy your finished prompt.

Your Prompt
prompt.txt

                                

What this prompt does

This prompt makes the AI design a dimensional data warehouse schema starting from the grain, which is the decision everything else hangs on. You set [business_context], [warehouse_platform], the [business_process] to model, and the [grain_definition], and the model builds a fact table at that exact grain with your [measures], degenerate dimensions, and foreign keys, partitioned by [partition_column] and clustered by [cluster_columns].

The structure works because it makes you commit to grain and slowly-changing-dimension handling before writing any DDL — getting the grain wrong is the mistake that forces a rebuild later. It generates a dim_date with fiscal support for [fiscal_year_start], an SCD Type 2 dim_customer, your [additional_dimensions], a bridge table for [many_to_many_relationship], and an accumulating snapshot for [process_milestones]. It then emits platform-tuned DDL, sample analytical queries including [sample_query_requirement], and a data dictionary. Every measure and column is documented up front, which heads off downstream arguments about what a number means.

When to use it

  • You're modeling a new warehouse and want the grain nailed down before anyone writes SQL.
  • You need fact and dimension tables with SCD Type 2 history on the dimensions that change.
  • You have a genuine many-to-many relationship that needs a clean bridge table.
  • You want to track time between process milestones with an accumulating snapshot.
  • You need DDL tuned for a specific platform's compression, distribution, and sort keys.
  • You want a data dictionary so business definitions are agreed before reporting starts.

Example output

Expect a schema design: DDL for the fct_ fact table at the stated grain with partitioning and clustering, dimension tables including a fiscal-aware dim_date and an SCD2 dim_customer, a bridge table, an accumulating snapshot fact, and platform-specific optimizations. It closes with sample queries (year-over-year, cohort, and your custom [sample_query_requirement]) and a data dictionary documenting each table and column.

Pro tips

  • Spend the most effort on [grain_definition] — state it as one row per what, per when. A fuzzy grain is what later forces a full rebuild.
  • List [measures] precisely and document each; ambiguous measures (is MRR net or gross?) cause the downstream arguments this prompt is meant to prevent.
  • Set [fiscal_year_start] correctly if the business doesn't run on a calendar year — a wrong fiscal boundary quietly breaks every period comparison.
  • Match [partition_column] and [cluster_columns] to how the table is queried; partitioning on a column nobody filters on adds cost without speeding queries.
  • Only add a bridge table when the relationship is truly many-to-many; forcing one onto a one-to-many relationship over-complicates joins.
  • Treat the SCD2 dim_customer effective dating as load-bearing — confirm the generated DDL has effective_from, effective_to, and is_current before building facts against it.

Frequently Asked Questions

Why does the prompt start from grain?
Grain defines exactly what one fact row represents, and every measure, dimension, and aggregation depends on it. Getting the grain wrong is the mistake that costs a full rebuild later, so the prompt forces you to commit to it before generating any DDL.
Does it handle slowly changing dimensions?
Yes, it builds dim_customer as SCD Type 2 with effective_from, effective_to, and an is_current flag so historical states are preserved. This lets point-in-time queries join facts to the version of the dimension that was current when the event happened.
Will the DDL be tuned for my specific warehouse?
The prompt generates DDL optimized for your chosen platform, covering column ordering, compression encodings, distribution or clustering keys, and sort keys. Because these options differ across platforms, specifying the right warehouse_platform variable matters for getting useful, platform-appropriate output.
Does it document what each measure means?
Yes, the output includes a data dictionary documenting every table and column with business definitions. Defining measures clearly up front is what prevents downstream disputes about whether a number like MRR is net, gross, or includes a particular adjustment.
Engr Mejba Ahmed

Need this built for real?

Engr Mejba Ahmed

AI Developer · Software Engineer

I'm Mejba — I design and ship production AI systems, automations, and full-stack apps. If you want this turned into a working solution for your team, let's talk.

More in Data Engineering & ETL Prompts

Engr Mejba Ahmed

Engr Mejba Ahmed

Claude Code Expert · Online

👋

Hey there!

Quick Actions

WhatsApp Instant reply

Chat on WhatsApp

+880 1723 741224 · Instant reply

Popular Questions

Engr Mejba Ahmed is connected
Engr Mejba Ahmed is typing...
Engr Mejba Ahmed avatar

✉ Want me to follow up? Drop your email

Engr Mejba Ahmed avatar

📞 Connect Directly

Choose how you'd like to reach me

WhatsApp

+880 1723 741224

Email

[email protected]

✓ Details sent! I'll get back to you shortly.

Powered by OpenAI

335+

Blog Posts

25

AI Courses

63

Projects

Services & Expertise

Pricing & Process

Learning & Resources

Connect & Support