database-design

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

Updated Mar 23, 2026
One-click install
npx skills add https://github.com/Helcio-Nogueira/Painel_Inteligente_Hackaton_2026 --skill database-design-helcio-nogueira
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: database-design
Source: https://github.com/Helcio-Nogueira/Painel_Inteligente_Hackaton_2026/tree/main/.agents/skills/database-design
Command: npx skills add https://github.com/Helcio-Nogueira/Painel_Inteligente_Hackaton_2026 --skill database-design-helcio-nogueira

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 painful migrations, slow queries, and costly rewrites. This Skill provides decision frameworks and reference material so you design schemas, pick tools, and optimize queries 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 context. - Schema Design Guidance: Principles for normalization, primary key types (UUID, ULID, auto-increment), timestamps, relationships, and ON DELETE behaviors. - Performance & Migrations: Indexing strategies, N+1 query detection, EXPLAIN ANALYZE workflow, and zero-downtime migration patterns. - 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 TypeScript API, ask for help choosing between Drizzle and Prisma, then design a normalized schema with proper composite indexes before writing any SQL. ## Quick Start Ask the assistant to help design a database schema for your project, including which database and ORM to use, and run the schema validator script on your Prisma schema to catch common issues.

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 Prisma and Drizzle for my project?▼

Choose Drizzle for edge deployments and small bundle sizes since it is lightweight and SQL-like. Choose Prisma when you want the best developer experience with schema-first design, built-in migrations, and Prisma Studio. Kysely fits when you want a type-safe SQL builder with maximum control.

How do I design a database schema with proper relationships?▼

Start by deciding normalization versus denormalization based on read patterns and update frequency. Use one-to-many with a foreign key on the child table, many-to-many with a junction table, and pick primary keys like UUID for distributed systems or auto-increment for simple apps.

PostgreSQL vs SQLite vs Turso, which database should I use?▼

Use PostgreSQL for full relational features and complex queries, SQLite for simple embedded or local apps, and Turso for edge deployment with ultra-low latency. For serverless PostgreSQL with branching, consider Neon. Match the choice to your deployment environment and query complexity.

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

N+1 happens when one query fetches parents and N additional queries fetch related records. Fix it with JOINs to load everything in one query, ORM eager loading, DataLoader batching for GraphQL, or subqueries. Use EXPLAIN ANALYZE first to confirm the bottleneck.

How do I run database migrations without downtime?▼

Never make breaking changes in one step. Add columns as nullable, backfill data, then add NOT NULL constraints. Create indexes with CREATE INDEX CONCURRENTLY to avoid blocking. For renames, add the new column, migrate data, deploy, then drop the old column.

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 fields. For composite indexes, put equality columns first and range columns last.