All skills
Skillintermediate
/design-schema - Design Database Schema
Design a database schema based on application requirements.
Claude Code Knowledge Pack7/10/2026
Overview
/design-schema - Design Database Schema
Design a database schema based on application requirements.
Steps
- Ask the user about the domain: entities, relationships, and business rules
- Identify the core entities and their attributes with data types
- Define primary keys: prefer UUIDs for distributed systems, auto-increment for simple apps
- Map relationships: one-to-one, one-to-many, many-to-many with junction tables
- Add foreign key constraints with appropriate ON DELETE behavior (CASCADE, SET NULL, RESTRICT)
- Design indexes for primary access patterns and common query filters
- Add unique constraints for business-unique fields (email, username, slug)
- Include audit columns: created_at, updated_at, deleted_at (soft delete)
- Consider normalization: aim for 3NF, denormalize only with clear performance justification
- Add check constraints for data validation (positive amounts, valid status values)
- Generate the schema as SQL DDL statements for the target database
- Create a visual representation of the schema as a text-based ERD
Rules
- Use consistent naming: snake_case for columns, plural for table names
- Every table must have a primary key
- Add indexes for all foreign keys and common WHERE clause columns
- Use appropriate column types (do not use VARCHAR for everything)
- Include created_at and updated_at timestamps on all tables
- Design for the most common queries, not edge cases
- Document each table's purpose with a comment