database-design
Database Design guides you through schema normalization, indexing strategies, and query optimization for both SQL and NoSQL systems. It covers normalization forms, denormalization trade-offs, index types, and migration patterns to help you build performant, maintainable databases. Use it when designing tables, fixing performance issues, or planning data migrations.
Database Design helps you create normalized schemas, plan indexing strategies, and optimize queries for SQL and NoSQL databases.
AI-generated summary based on this skill's SKILL.md
Install
CloudAI-X/claude-workflow-v2/database-design · repository language: Python
git clone https://github.com/CloudAI-X/claude-workflow-v2
cp -r claude-workflow-v2/skills/database-design ~/.claude/skills/database-designnpx skillfed install CloudAI-X/claude-workflow-v2/database-designFrequently asked questions
AI-generated answers based on this skill's SKILL.md and metadata
How do I design a database schema that performs well?
Database Design helps you structure schemas through normalization principles, index strategies, and denormalization trade-offs. Start by identifying entities and relationships, apply normalization forms (1NF through 3NF) to eliminate redundancy, then selectively denormalize where query patterns justify it. Use composite indexes for common filter and join operations, and plan migrations carefully to avoid downtime.
What's the best way to fix an N+1 query problem?
Database Design covers N+1 optimization by teaching you to batch queries, use eager loading in your ORM, or restructure joins. The core issue is fetching a parent record then looping to fetch children individually. Solutions include JOIN operations, ORM relationship loading (like includes/joins in Rails), or query result caching with Redis for frequently accessed data.
How should I approach database indexing strategy?
Database Design guides index creation by analyzing your query patterns first. Create indexes on columns used in WHERE, JOIN, and ORDER BY clauses. Use composite indexes when multiple columns filter together. Monitor with EXPLAIN ANALYZE to confirm indexes are used. Avoid over-indexing—each index slows writes. Balance read performance against write costs based on your workload.
What are zero downtime database migration patterns?
Database Design teaches safe migration patterns: add new columns as nullable, deploy code reading both old and new columns, backfill data gradually, then remove old columns in a later deployment. For schema changes, use feature flags and blue-green deployments. Test migrations on production-scale data first. Connection pooling configuration ensures requests don't timeout during long operations.
When should I denormalize vs. normalize my database?
Database Design explains that normalization (1NF–3NF) eliminates redundancy and maintains consistency, ideal for transactional systems. Denormalize when read performance is critical and updates are infrequent—store computed aggregates or duplicate data strategically. Analyze query patterns: if you always join the same tables, denormalization may be justified. Use caching (Redis) as an alternative before denormalizing.
What ORM best practices should I follow?
Database Design covers ORM best practices including connection pooling configuration to reuse database connections, eager loading to prevent N+1 queries, and batch operations for bulk inserts. Use parameterized queries to prevent SQL injection. Understand your ORM's lazy vs. eager loading behavior. Monitor connection pool exhaustion and query counts in production to catch performance regressions early.
SKILL.md
rendered from the published skill — quoted content, verbatim
Database Design
When to Load
- Trigger: Schema design, migrations, query optimization, indexing strategies, data modeling, N+1 fixes
- Skip: No database work involved in the current task
Database Design Workflow
Copy this checklist and track progress:
Database Design Progress:
- [ ] Step 1: Identify entities and relationships
- [ ] Step 2: Normalize schema (3NF minimum)
- [ ] Step 3: Evaluate denormalization needs
- [ ] Step 4: Design indexes for query patterns
- [ ] Step 5: Write and optimize critical queries
- [ ] Step 6: Plan migration strategy
- [ ] Step 7: Configure connection pooling
- [ ] Step 8: Validate against anti-patterns checklist
Schema Design Principles
Normalization Forms
``` 1NF: Atomic values, no repeating groups 2NF: 1NF + no partial dependencies (all non-key columns depend on full PK) 3NF: 2NF +
(truncated - see the full file via the links below)
Read as markdown · JSON record · Browse the source repository
File tree — 1 file
skills/database-design/SKILL.md