database-design

Guides database selection, schema design, indexing, and query optimization decisions.

Updated Aug 5, 2026
One-click install
npx skills add https://github.com/pd-phuc/laravel-template --skill database-design-pd-phuc
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: database-design
Source: https://github.com/pd-phuc/laravel-template/tree/main/.claude/skills/database-design
Command: npx skills add https://github.com/pd-phuc/laravel-template --skill database-design-pd-phuc

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve? Choosing the wrong database, ORM, or schema structure early in a project leads to performance bottlenecks, painful migrations, and costly rewrites. This Skill provides decision frameworks and reference material so you make informed database choices based on your actual context instead of defaults. ## Core Features & Use Cases - Database & ORM Selection: Decision trees comparing PostgreSQL, Neon, Turso, SQLite, PlanetScale, and ORMs like Drizzle, Prisma, and Kysely based on deployment environment and query complexity. - Schema Design Guidance: Principles for normalization, primary key selection (UUID, ULID, auto-increment), timestamps, relationships, and foreign key ON DELETE behavior. - Performance & Migrations: Indexing strategies, N+1 query detection, EXPLAIN ANALYZE workflow, and zero-downtime migration patterns for serverless databases. - Schema Validation Script: A Python script that scans Prisma schemas for missing IDs, timestamps, naming issues, and missing indexes. - Use Case: When starting a new app, ask the AI to help choose between SQLite and PostgreSQL, design the schema with proper indexes, and validate your Prisma schema before committing. ## Quick Start Ask the AI to help you choose a database and design the schema for your new project, mentioning your deployment environment and expected query patterns.

Frequently Asked Questions about database-design

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I choose between PostgreSQL, SQLite, and Turso for my app?▼

Choose based on deployment context: PostgreSQL for full relational features and complex queries, SQLite for simple embedded or local apps, and Turso for edge deployment with ultra-low latency. Serverless PostgreSQL options like Neon fit when you need branching and scale-to-zero.

Drizzle vs Prisma: which ORM should I use?▼

Drizzle is best for edge deployment and small bundle size with a SQL-like API, while Prisma offers better developer experience with schema-first migrations and tooling. Kysely suits those wanting a type-safe SQL query builder with manual migrations.

How do I fix N+1 query problems in my database?▼

N+1 occurs when one query fetches parents and N additional queries fetch related records. Fix it with JOINs, ORM eager loading, DataLoader batching for GraphQL, or subqueries that fetch related data in a single query.

When should I add indexes to database columns?▼

Index columns used in WHERE clauses, JOIN conditions, ORDER BY, and foreign keys. Avoid over-indexing write-heavy tables, low-cardinality columns, and rarely queried columns since indexes slow down inserts.

How do I run zero-downtime database migrations?▼

Never make breaking changes in one step: add columns as nullable then backfill, create indexes with CREATE INDEX CONCURRENTLY, and rename columns by adding the new one, migrating data, then dropping the old. Always test on a data copy first.

What does the schema validator script check in Prisma schemas?▼

The schema_validator.py script checks Prisma schemas for PascalCase model naming, missing @id fields, missing createdAt timestamps, and foreign keys lacking @@index declarations. It outputs a JSON report of issues found as warnings.