spencerpauly/awesome-cursor-skills/database-design
Claude Code and agent skill by spencerpauly/awesome-cursor-skills
- community
Checking that the SKILL.md file is still in the repository.
Design database schemas — tables, relationships, indexes, constraints, and ORM setup. Covers relational design, normalization, and common patterns.
Install
npx vskill@latest install spencerpauly/awesome-cursor-skills/database-designSKILL.md
The same SKILL.md was published earlier as spencerpauly/awesome-cursor-skills/database-design.
Database Design
Design a database schema from requirements.
Workflow
1. Identify Entities
From the requirements, extract the core entities (nouns):
- Users, Teams, Projects, Tasks, Comments, etc.
- Each entity becomes a table
2. Define Relationships
| Relationship | Implementation | |
|---|---|---|
| One-to-one | Foreign key with unique constraint, or embed in same table | |
| One-to-many | Foreign key on the "many" side | |
| Many-to-many | Junction/join table | |
| Self-referential | Foreign key pointing to same table (e.g. parent_id) |
3. Design the Schema
For each table:
4. Apply Best Practices
Primary keys:
- Use
UUIDfor distributed systems or public-facing IDs - Use
SERIAL/BIGSERIALfor internal-only IDs (faster joins)
Timestamps:
- Always add
created_atandupdated_at - Use
TIMESTAMPTZ(with timezone), neverTIMESTAMP
Naming:
- Tables: plural snake_case (
users,project_members) - Columns: singular snake_case (
user_id,created_at) - Indexes:
idx_<table>_<columns>(idx_users_email)
Constraints:
NOT NULLon everything unless it's genuinely optionalUNIQUEon natural keys (email, slug, external IDs)REFERENCESwithON DELETEbehavior (CASCADE, SET NULL, RESTRICT)CHECKconstraints for enums or value ranges
5. Add Indexes
When to index:
- Foreign keys (almost always)
- Columns in WHERE clauses
- Columns in ORDER BY
- Columns in JOIN conditions
When NOT to index:
- Small tables (<1000 rows)
- Columns with low cardinality (boolean, status with 3 values)
- Columns that are rarely queried
6. ORM Setup
Prisma:
Drizzle:
Common Patterns
Soft deletes: Add deleted_at TIMESTAMPTZ instead of actually deleting rows Audit log: Separate audit_events table with entity_type, entity_id, action, actor_id, payload Tags/labels: Junction table (task_tags) with task_id + tag_id Tree/hierarchy: parent_id self-reference, or materialized path (/1/4/7/) Polymorphic associations: Use entity_type + entity_id columns (avoid if possible, prefer separate FKs)
Tips
- Start normalized (3NF), denormalize only when you have measured performance problems
- Don't store derived data unless you have a caching/invalidation strategy
- Use database enums or check constraints for status fields, not free-text
- Always think about what happens when you delete a parent record
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingresources/database-design/SKILL.md
Popularity
- Repository stars
- 683
- Repository forks
- 108
- 7-day trend score
- 33
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/spencerpauly/awesome-cursor-skills/database-design)