Skip to content
Back to skills

Bigquery Schema Design

ASecurity

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".

  • 15 stars
  • 0 votes
  • 0 copies
  • 10 views
  • Added May 28, 2026
ai-agentsjavascriptgojavarailsgitdocumentation

Security analysis

A100/100

Pro scans all 7 files and shows the line behind each finding

Scanned May 28, 2026

npx -y skills add justvinhhere/bigquery-expert --skill bigquery-schema-design --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Bigquery Schema Design?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Bigquery Schema Design
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/justvinhhere-bigquery-schema-design/badge)](https://www.skillsdirectory.com/skills/justvinhhere-bigquery-schema-design)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: bigquery-schema-design
description: >
  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".
---

# 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

| Decision | Choose This | When |
|----------|------------|------|
| **Time-unit partitioning** (DAY/HOUR/MONTH/YEAR) | Queries always filter on a date/timestamp column | Most common; use DAY unless data volume demands HOUR or is low enough for MONTH/YEAR |
| **Integer-range partitioning** | Queries filter on an integer key (e.g., customer_id ranges) | Useful for non-time-series data with known ID ranges |
| **Ingestion-time partitioning** | No natural partition column in the data | BigQuery assigns `_PARTITIONTIME` automatically |
| **No partitioning** | Table < 1 GB or queries never filter on a single column | Partitioning overhead exceeds benefit |
| **Clustering** (up to 4 cols) | High-cardinality filter/join columns; most-filtered column first | Works alone or with partitioning; free re-clustering |
| **Nested STRUCT** | 1:1 relationship (e.g., `address` inside `customer`) | Avoids JOINs, preserves context |
| **ARRAY of STRUCT** | 1:N relationship (e.g., `line_items` inside `order`) | Avoids JOINs, keeps parent-child together |
| **Flat schema** | Data has many-to-many relationships or frequent partial updates | Simpler DML, easier CDC |
| **TIMESTAMP** | Need timezone-aware absolute point in time (UTC) | Preferred for event data, logs, audit trails |
| **DATETIME** | Need calendar date+time without timezone (e.g., scheduling) | No timezone conversion; local-time semantics |
| **INT64 for IDs** | IDs are numeric and used in joins/aggregations | Smaller storage, faster comparisons |
| **STRING for IDs** | IDs contain letters, hyphens, or are UUIDs | Avoid casting overhead |
| **NUMERIC** | Exact decimal arithmetic (financial data) | 38 digits precision, no floating-point errors |
| **FLOAT64** | Approximate 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.

Files in this skill

  • SKILL.md4.8 KB
  • references/01-partitioning-strategies.md1.9 KB
  • references/02-clustering.md2.2 KB
  • references/03-nested-repeated-fields.md1.8 KB
  • references/04-denormalization-patterns.md2.3 KB
  • references/05-table-types.md2.1 KB
  • references/06-data-type-best-practices.md2 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.