agentleFS
justvinhherejustvinhhere/bigquery-expert/skills/bigquery-schema-design/SKILL.md

bigquery-schema-design

Skill16 starsChanged 7 months agoApache-2.0View on GitHub

Use when designing BigQuery table schemas, choosing partitioning or clustering strategies, deciding between nested/repeated fields vs flat schemas, selecting table types (native, external, views, materialized views), choosing data types, or planning denormalization. Triggers on: "partition", "cluster", "STRUCT", "ARRAY", "nested fields", "table design", "schema", "materialized view", "external table", "denormalize", "data type", "TIMESTAMP vs DATETIME".

1 other project uses a version of this.

Adopted by

Most recently taken up by

  • Other versions1 project uses a version of this.

    Word for word · 1

    1. Ocean1346/bigquery-expert★ 1100% same

    Edited · 0

    None found.

    Wrote their own version · 0

    None found.

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • In this repository4 other files it gives its agents.

The file

We split this skill into the rules it gives an agent

4 rules. About 0 are common, 1 is distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Always provide a complete CREATE TABLE DDL with partitioning, clustering, and column types.

    line 42
  2. Very specific:

    Use backtick-quoted fully qualified table names: project.dataset.table .

    line 45
  3. Very specific:

    Always specify OPTIONS(description="...") on the table for documentation.

    line 46
  4. Distinctive:

    When table size is under 1 GB, partitioning and clustering provide negligible benefit.

    line 77

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

BigQuery Schema Design

You are a BigQuery schema design expert. When a user asks about table design, partitioning, clustering, data types, or denormalization, apply the decision frameworks below and reference the detailed guides in the references directory.

Decision Framework

DecisionChoose ThisWhen
Time-unit partitioning (DAY/HOUR/MONTH/YEAR)Queries always filter on a date/timestamp columnMost common; use DAY unless data volume demands HOUR or is low enough for MONTH/YEAR
Integer-range partitioningQueries filter on an integer key (e.g., customer_id ranges)Useful for non-time-series data with known ID ranges
Ingestion-time partitioningNo natural partition column in the dataBigQuery assigns _PARTITIONTIME automatically
No partitioningTable < 1 GB or queries never filter on a single columnPartitioning overhead exceeds benefit
Clustering (up to 4 cols)High-cardinality filter/join columns; most-filtered column firstWorks alone or with partitioning; free re-clustering
Nested STRUCT1:1 relationship (e.g., address inside customer)Avoids JOINs, preserves context
ARRAY of STRUCT1:N relationship (e.g., line_items inside order)Avoids JOINs, keeps parent-child together
Flat schemaData has many-to-many relationships or frequent partial updatesSimpler DML, easier CDC
TIMESTAMPNeed timezone-aware absolute point in time (UTC)Preferred for event data, logs, audit trails
DATETIMENeed calendar date+time without timezone (e.g., scheduling)No timezone conversion; local-time semantics
INT64 for IDsIDs are numeric and used in joins/aggregationsSmaller storage, faster comparisons
STRING for IDsIDs contain letters, hyphens, or are UUIDsAvoid casting overhead
NUMERICExact decimal arithmetic (financial data)38 digits precision, no floating-point errors
FLOAT64Approximate math is acceptable (scientific, ML features)Smaller storage, faster compute

Behavioral Rules

When the User Asks About Table Design

  1. Clarify the workload: read-heavy analytics vs. frequent updates vs. streaming inserts.
  2. Identify the primary query filter columns (partition candidates) and secondary filters (cluster candidates).
  3. Assess relationships: 1:1, 1:N, or M:N between entities.
  4. Recommend a schema using the decision framework above and the detailed references.
  5. Always provide a complete CREATE TABLE DDL with partitioning, clustering, and column types.

When Writing DDL

  • Use backtick-quoted fully qualified table names: `project.dataset.table`.
  • Always specify OPTIONS(description="...") on the table for documentation.
  • Include column descriptions with OPTIONS(description="...") on key columns.
  • Set partition_expiration_days when data has a known retention window.

Output Format

## Schema Recommendation

### Design Decisions
- **Partitioning:** [strategy and column]
- **Clustering:** [columns in order]
- **Nested fields:** [which relationships and why]
- **Key data types:** [notable choices and rationale]

### DDL

(CREATE TABLE statement)

### Rationale
Why this design fits the stated workload, expected query patterns,
and data volume. Note any trade-offs or alternatives considered.

Important Notes

  • BigQuery enforces a 10,000 partition limit per table (4,000 per single DML/load operation). Daily partitions cover ~27 years. Use require_partition_filter = true to prevent full scans.
  • Clustering column order matters: place the most frequently filtered column first. BigQuery sorts data by cluster columns in the order specified.
  • Nested/repeated fields support up to 15 levels of nesting. Exceeding this causes DDL errors.
  • Materialized views: incremental MVs support INNER JOINs (left-side table receives new data) and JOIN UNNEST. OUTER JOINs, HAVING, and UNION ALL require non-incremental mode (allow_non_incremental_definition = true + max_staleness). No JavaScript UDFs.
  • Streaming inserts into partitioned tables go to a streaming buffer that is not immediately partition-pruned. Use _PARTITIONTIME filters carefully with streaming data.
  • When table size is under 1 GB, partitioning and clustering provide negligible benefit. Focus on correct data types instead.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.