database-design-patterns
Database schema design patterns and optimization strategies for relational and NoSQL databases. Use when designing database schemas, optimizing query performance, or implementing data persistence layers at scale.
Best use case
database-design-patterns is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Database schema design patterns and optimization strategies for relational and NoSQL databases. Use when designing database schemas, optimizing query performance, or implementing data persistence layers at scale.
Teams using database-design-patterns should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/database-design-patterns/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How database-design-patterns Compares
| Feature / Agent | database-design-patterns | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Database schema design patterns and optimization strategies for relational and NoSQL databases. Use when designing database schemas, optimizing query performance, or implementing data persistence layers at scale.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# Database Design Patterns Expert guidance for designing scalable database schemas, optimizing query performance, and implementing robust data persistence layers across relational and NoSQL databases. ## When to Use This Skill - Designing database schemas for new applications - Optimizing slow queries and database performance - Choosing between normalization and denormalization strategies - Implementing partitioning, sharding, or replication strategies - Migrating between database technologies (SQL to NoSQL or vice versa) - Designing for high availability and disaster recovery - Implementing caching strategies and read replicas - Scaling databases horizontally or vertically - Ensuring data consistency in distributed systems ## Core Concepts ### Data Modeling Design schemas that reflect business domain, access patterns, and consistency requirements. Balance normalization (data integrity) with denormalization (read performance) based on workload characteristics. ### ACID vs. BASE - **ACID** (Relational): Atomicity, Consistency, Isolation, Durability - strong guarantees - **BASE** (NoSQL): Basically Available, Soft state, Eventually consistent - flexibility ### CAP Theorem Distributed systems choose two of three: Consistency, Availability, Partition Tolerance. ### Polyglot Persistence Use the right database for each use case: PostgreSQL for transactions, MongoDB for documents, Redis for caching, Elasticsearch for search, Cassandra for time-series, Neo4j for graphs. ## Quick Reference | Task | Load reference | | --- | --- | | Core database principles (ACID, BASE, CAP) | `skills/database-design-patterns/references/core-principles.md` | | Schema patterns (normalization, star schema, documents) | `skills/database-design-patterns/references/schema-design-patterns.md` | | Index types and strategies (B-tree, hash, covering) | `skills/database-design-patterns/references/indexing-strategies.md` | | Partitioning and sharding approaches | `skills/database-design-patterns/references/partitioning-patterns.md` | | Replication modes (primary-replica, multi-leader) | `skills/database-design-patterns/references/replication-patterns.md` | | Query optimization and caching | `skills/database-design-patterns/references/query-optimization.md` | ## Workflow ### Phase 1: Requirements Analysis 1. Identify access patterns (read-heavy vs. write-heavy) 2. Determine consistency requirements (strong vs. eventual) 3. Estimate data volume and growth rate 4. Define SLA requirements (latency, availability) ### Phase 2: Schema Design 1. Model entities and relationships 2. Choose normalization level based on workload 3. Design for query patterns, not just storage 4. Consider data distribution strategy (partitioning/sharding) ### Phase 3: Performance Optimization 1. Analyze query execution plans (`EXPLAIN ANALYZE`) 2. Add indexes for frequent queries 3. Implement caching where appropriate 4. Configure connection pooling 5. Monitor and iterate ### Phase 4: Scaling Strategy 1. Implement read replicas for read scaling 2. Consider partitioning for large tables (>100M rows) 3. Plan sharding strategy for horizontal scaling 4. Design for high availability with replication ## Common Mistakes **Over-normalization**: Too many joins slow down reads. Denormalize for read-heavy workloads. **Missing indexes**: Analyze query patterns and add indexes for frequent WHERE/JOIN columns. **Wrong index type**: Use composite indexes with correct column order (equality first, then range). **Ignoring replication lag**: Handle eventual consistency with read-your-writes pattern. **Poor partitioning key**: Choose keys that distribute data evenly and align with query patterns. **N+1 queries**: Use JOINs or batch loading instead of querying in loops. **Inefficient pagination**: Use keyset pagination instead of OFFSET for large datasets. **Connection exhaustion**: Implement connection pooling sized for your workload. ## Best Practices 1. **Model for access patterns** - Design schemas around how data will be queried 2. **Index strategically** - Index frequently queried columns, avoid over-indexing 3. **Partition large tables** - Use for tables >100M rows or time-series data 4. **Replicate for reads** - Primary-replica for read scaling, multi-leader for geo-distribution 5. **Optimize queries** - Analyze execution plans, avoid N+1, use proper pagination 6. **Cache hot data** - Application-level caching with appropriate TTLs 7. **Pool connections** - Size connection pools based on workload 8. **Monitor continuously** - Track query performance, index usage, replication lag 9. **Plan for growth** - Design for 3x current load 10. **Choose consistency wisely** - Match consistency level to business requirements ## Resources **Books**: - "Designing Data-Intensive Applications" (Kleppmann) - "High Performance MySQL" (Schwartz) **Sites**: - use-the-index-luke.com - PostgreSQL documentation - MongoDB documentation **Tools**: - EXPLAIN ANALYZE - pg_stat_statements - Percona Toolkit - pt-query-digest
Related Skills
distinctive-frontend-design
Creates distinctive, production-grade frontend interfaces that avoid generic AI aesthetics. Guides bold aesthetic direction, typography, color, motion, and spatial composition for memorable UI. Use when building frontend components, pages, applications, or interfaces, or when the user asks for UI/UX design, styling, or visually striking interfaces.
discover-database
Automatically discover database skills when working with SQL, PostgreSQL, MongoDB, Redis, database schema design, query optimization, migrations, connection pooling, ORMs, or database selection. Activates for database design, optimization, and implementation tasks.
dev-api-design
Production-grade API design patterns for REST, GraphQL, gRPC, and tRPC. Covers API architecture, OpenAPI/Swagger specs, versioning/deprecation, authentication/authorization, rate limiting, pagination, error models, contract testing, and developer documentation.
designing-databases
データベーススキーマ設計と最適化を支援します。正規化戦略、インデックス設計、パフォーマンス最適化を提供します。データモデル設計、データベース構造の最適化が必要な場合に使用してください。
designer-skills
Designer subsystem patterns for LlamaFarm. Covers React 18, TanStack Query, TailwindCSS, and Radix UI.
design-ui-ux-pro-max
UI/UX design intelligence. 50 styles, 21 palettes, 50 font pairings, 20 charts, 9 stacks (React, Next.js, Vue, Svelte, SwiftUI, React Native, Flutter, Tailwind, shadcn/ui). Actions: plan, build, create, design, implement, review, fix, improve, optimize, enhance, refactor, check UI/UX code. Projects: website, landing page, dashboard, admin panel, e-commerce, SaaS, portfolio, blog, mobile app, .html, .tsx, .vue, .svelte. Elements: button, modal, navbar, sidebar, card, table, form, chart. Styles: glassmorphism, claymorphism, minimalism, brutalism, neumorphism, bento grid, dark mode, responsive, skeuomorphism, flat design. Topics: color palette, accessibility, animation, layout, typography, font pairing, spacing, hover, shadow, gradient. Integrations: shadcn/ui MCP for component search and examples.
design-tokens
Apply design token patterns using Tailwind CSS 4 @theme directive: CSS variables, semantic naming, color systems, typography scales, spacing, dark mode. Use when designing UI systems, reviewing design consistency, or establishing brand guidelines. Integrates with frontend-design skill for aesthetic execution.
design-taste-frontend
Senior UI/UX Engineer. Architect digital interfaces overriding default LLM biases. Enforces metric-based rules, strict component architecture, CSS hardware acceleration, and balanced design engineering.
design-microservices
マイクロサービス設計エージェント - ターゲットアーキテクチャ、変換計画、運用計画の策定。/design-microservices [対象パス] で呼び出し。
design-layered-backend-architecture
Design or review a layered backend architecture (routes, controllers, services, repositories) for HTTP APIs and microservices.
design-api
Triggered when user asks to design APIs, create API specifications, or plan API endpoints. Automatically delegates to the api-designer agent.
debug-log-patterns
Language-specific debug logging patterns and best practices. Reference when adding instrumentation for Dart/Flutter, Kotlin/Android, Swift/iOS, or JavaScript/TypeScript applications.