Database Designer

Use when the user asks to design database schemas, plan data migrations, optimize queries, choose between SQL and NoSQL, or model data relationships.

Development / Engineeringdevelopmentengineering
by AgentVoltv1.0.0Published 1y ago1 install
Free to sign up · every skill included with AgentVolt Pro

Before & after

Same prompt, same agent — the only difference is the skill.

PromptDesign a schema for multi-tenant SaaS with millions of user records.
Beforegeneric AI agent
You'll need to decide between SQL and NoSQL based on your query patterns and consistency requirements. For a multi-tenant system, you'll want to consider isolation strategies and how to partition data. You should think about indexing strategies to keep query performance acceptable at scale. You might also want to plan for sharding early if you're expecting millions of records. What specific features does your application need to support?
Afterwith Database Designer
MULTI-TENANT SAAS SCHEMA DESIGN (SQL, row-level security)

FUNDAMENTAL DECISIONS:
SQL (PostgreSQL) chosen over NoSQL because: ACID transactions needed for billing accuracy, relational queries (cross-customer analytics), strong data integrity. Row-level security via tenant_id column + RLS policy = security at DB layer.

CORE TABLES:

table tenants (id, name, plan_tier, created_at)
Multi-tenant anchor. One row = one customer account.

table users (id, tenant_id, email, password_hash, role, created_at)
Index: (tenant_id, email). RLS policy: users can only access rows where tenant_id matches their session.

table events (id, tenant_id, user_id, event_type, properties_jsonb, created_at)
Large table (scale target: 100M+ rows). Partitioning by tenant_id or created_at (monthly). Index: (tenant_id, created_at DESC) for fast "events for tenant in last 30 days" queries.

table subscriptions (id, tenant_id, plan_tier, status, billing_cycle, renewal_date, amount_cents, currency, created_at, updated_at)
Billing source-of-truth. Immutable insert pattern: never UPDATE, only insert new rows (soft delete old). Audit trail preserved.

RELATIONSHIP DIAGRAM (simplified):
tenants 1:many users
tenants 1:many subscriptions
tenants 1:many events
users 1:many events

PARTITIONING STRATEGY (scale plan):
At 10M events/month (120M/year), partition events table by created_at (monthly partitions). This: 1) keeps index scan fast (only needed partition scanned), 2) enables easy archival (drop old partitions to cold storage).

MIGRATION PLAN:
V1 (week 1): Create schema, populate tenants/users/subscriptions from production. Keep old system live in parallel (reads only).
V2 (week 2): Dual-write new events table while legacy system still active. Verify parity.
V3 (week 3): Cutover: switch application to new schema, backfill historical events if needed, decommission legacy.

BACKUP/RECOVERY:
Daily automated backups. Point-in-time recovery enabled (WAL archiving). Tenant-level restoration possible (restore single tenant to test environment without affecting others).

QUERY PATTERNS OPTIMIZED:
"Show me events for tenant X in last 7 days" → Partition + index scan = 200ms (millions of total events). "Billing revenue by plan_tier last month" → denormalized summary table refreshed nightly = 50ms. "Export user data for GDPR" → tenant_id filter returns exact set = 500ms for 1M users.

About this skill


name: database-designer description: Use when Use when the user asks to design database schemas, plan data migrations, optimize queries, choose between SQL and NoSQL, or model data relationships.

Database Designer

Use when the user asks to design database schemas, plan data migrations, optimize queries, choose between SQL and NoSQL, or model data relationships.

What you get

  • Public GitHub repo (alirezarezvani/claude-skills)
  • the database-designer skill folder with SKILL.md. Part of a 337-skill / 30-agent / 70-command install.

Customize your output

  • Fork the repo and adapt the skill's instructions and references to your workflow.

Example output

Activates automatically when your request matches Database Designer; chains with the other skills, agents, and commands in the collection.

Best for

Creators, builders, and teams using Claude Code.

SKILL.md preview

SKILL.md
---
name: database-designer
description: Use this skill when designing database schemas, planning migrations, optimizing queries, choosing between SQL and NoSQL, or modeling data relationships.
version: 1.0.0
category: Development / Engineering
author: AgentVolt
license: proprietary
tags:
  - development
  - engineering
---

# Database Designer

Designs database schemas, plans data migrations, optimizes queries, and models data relationships across SQL and NoSQL systems.

## When to use

… (sign up to view the full skill)
Sign up to view, copy, and install the full skill

More development skills

View all Development skills →