Skills database-design
📦

database-design

Safe

Master database design and schema decisions

Developers struggle with database choices and schema design pitfalls. This skill teaches decision frameworks for selecting databases, designing schemas, and optimizing queries based on context.

Supports: Claude Codex Code(CC)
🥉 73 Bronze
1

Download the skill ZIP

2

Upload in Claude

Go to Settings → Capabilities → Skills → Upload skill

3

Toggle on and start using

Test it

Using "database-design". I need to choose a database for a real-time chat application with 10,000 concurrent users, global distribution, and sub-50ms latency requirements.

Expected outcome:

For global real-time chat with strict latency requirements, consider Turso (edge SQLite) for presence and message metadata, combined with a primary PostgreSQL instance for durable storage. Turso provides edge deployment reducing latency, while PostgreSQL handles complex queries and transactions. Alternative: PlanetScale for MySQL compatibility with global branching.

Using "database-design". Should I normalize my user preferences table or store as JSONB?

Expected outcome:

Store as JSONB if: preferences are rarely queried individually, schema evolves frequently, and you always fetch the complete set. Normalize if: you need to query specific preferences in WHERE clauses, different preferences have different update frequencies, or you need foreign key constraints. Hybrid approach: JSONB for flexible preferences with a normalized table for frequently-filtered settings.

Security Audit

Safe
v1 • 2/24/2026

All static analyzer findings are false positives. The 'external_commands' detections are markdown code fence blocks (```) used for educational diagrams, not executable shell commands. The 'weak cryptographic algorithm' flags reference UUID/ULID discussions in documentation context. The schema_validator.py is a legitimate local Python script for Prisma schema validation. This is a documentation-only skill teaching database design principles.

8
Files scanned
489
Lines analyzed
0
findings
1
Total audits
No security issues found
Audited by: claude

Quality Score

45
Architecture
100
Maintainability
87
Content
32
Community
100
Security
91
Spec Compliance

What You Can Build

New project database setup

A startup founder building an MVP needs guidance on choosing between PostgreSQL, SQLite, or serverless options. The skill provides a decision tree based on scalability needs, budget, and deployment preferences.

Schema design review

A backend engineer designing a new feature needs help modeling user relationships, timestamps, and foreign key constraints. The skill reviews normalization trade-offs and relationship patterns.

Query performance troubleshooting

A developer experiencing slow queries needs to understand indexing strategies and N+1 problems. The skill explains EXPLAIN ANALYZE interpretation and composite index design.

Try These Prompts

Beginner: Database Selection
I am building a {project_type} application with {expected_users} users. My budget is {budget_level} and I need {specific_requirements}. Based on the database selection guide, recommend the best database option and explain the trade-offs.
Intermediate: Schema Design Review
Review my schema design for {table_name} table. I need to store {data_fields} with relationships to {related_tables}. Check if my approach follows normalization principles, has appropriate indexes, and uses the correct relationship types.
Advanced: Query Optimization
My query for {query_description} is taking {execution_time}. Here is the EXPLAIN ANALYZE output: {explain_output}. Identify the bottleneck and recommend specific indexing or query restructuring strategies.
Expert: Migration Strategy
I need to migrate from {current_schema} to {target_schema} with zero downtime. The table has {row_count} rows and serves {traffic_level} traffic. Design a migration strategy using the techniques from the migrations guide.

Best Practices

  • Always define created_at and updated_at timestamps using TIMESTAMPTZ for timezone awareness
  • Use UUID or ULID primary keys for distributed systems to avoid enumeration attacks and enable offline ID generation
  • Create composite indexes matching your most common query patterns with equality columns before range columns

Avoid

  • Defaulting to PostgreSQL for simple applications where SQLite would suffice, adding unnecessary infrastructure complexity
  • Creating indexes on every column without considering write performance impact and low-cardinality inefficiency
  • Using SELECT * in production queries instead of explicitly selecting needed columns

Frequently Asked Questions

When should I choose SQLite over PostgreSQL?
Choose SQLite for: embedded applications, local development, read-heavy workloads under 100K requests/day, single-writer scenarios, or when simplicity matters more than features. Choose PostgreSQL for: concurrent writes, advanced SQL features (CTEs, window functions), row-level security, complex transactions, or when you need provenance and audit trails.
What is the N+1 query problem and how do I fix it?
N+1 occurs when you fetch parent records (1 query) then iterate to fetch related records (N queries). Fix with: JOINs to combine data in one query, eager loading in ORMs, DataLoader for batching in GraphQL, or subqueries to fetch all related records at once. Always use EXPLAIN ANALYZE to verify the fix works.
How do I decide between Drizzle, Prisma, and Kysely?
Drizzle: Lightweight, SQL-like syntax, good for serverless and edge. Prisma: Full-featured ORM with migrations, type generation, and studio UI. Kysely: TypeScript-first query builder with strict type safety. Choose Drizzle for minimalism, Prisma for full ORM needs, or Kysely for type-safe query building without ORM abstraction.
What columns should I index for optimal performance?
Index columns used in: WHERE clauses for filtering, JOIN conditions for relationships, ORDER BY for sorting, and foreign key columns for relationship queries. Avoid indexing: low-cardinality columns (boolean, gender), columns rarely used in queries, or tables with heavy write traffic where index maintenance slows inserts.
How do I safely migrate a large table with zero downtime?
Use expand-and-contract pattern: Phase 1 (expand) adds new column/table while keeping old. Phase 2 backfills data and dual-writes. Phase 3 migrates reads gradually. Phase 4 (contract) removes old column/table after verification. Use batch processing for backfill to avoid lock contention, and feature flags for gradual rollout.
What is the difference between Neon, Supabase, and self-hosted PostgreSQL?
Neon: Serverless PostgreSQL with database branching (like git), auto-scaling, and pay-per-use pricing. Supabase: PostgreSQL plus real-time subscriptions, authentication, storage, and edge functions as a backend platform. Self-hosted: Full control over configuration, extensions, and costs but requires operational expertise. Choose Neon for serverless, Supabase for full-stack features, self-hosted for control.