database-design

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

Updated Aug 11, 2026
One-click install
npx skills add https://github.com/DucCuong159/Realtime-chatapp --skill database-design-duccuong159
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: database-design
Source: https://github.com/DucCuong159/Realtime-chatapp/tree/main/.agent/skills/database-design
Command: npx skills add https://github.com/DucCuong159/Realtime-chatapp --skill database-design-duccuong159

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve? Choosing the wrong database, ORM, or indexing strategy leads to slow queries, painful migrations, and costly rewrites. This Skill provides structured decision frameworks so you pick the right database and design schemas 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 & Indexing Guidance: Principles for normalization, primary key selection, timestamps, relationships, composite indexes, and index type selection (B-tree, GIN, HNSW). - Query Optimization & Safe Migrations: N+1 detection strategies, EXPLAIN ANALYZE workflow, and zero-downtime migration patterns for serverless databases. - Use Case: When building a new edge-deployed app, use this Skill to decide between Turso and Neon, choose Drizzle as the ORM, design the schema with proper foreign keys, and validate it with the included schema validator script. ## Quick Start Ask the AI to help you choose a database and design a schema for your project, describing your deployment environment and 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, Neon, Turso, and SQLite?

Choose based on deployment context: PostgreSQL for full relational features, Neon for serverless PostgreSQL with branching, Turso for edge deployment with low latency, and SQLite for simple embedded or local apps. Consider query complexity, edge requirements, and global distribution needs.

Drizzle vs Prisma: which ORM should I use?

Drizzle is best for edge deployment and small bundle size with SQL-like syntax, while Prisma offers better developer experience with schema-first migrations and studio tooling. Kysely fits when you want a type-safe SQL query builder with maximum control.

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 fix N+1 query problems?

Solve N+1 by using JOINs to fetch related data in one query, eager loading through your ORM, DataLoader for batching in GraphQL, or subqueries. Use EXPLAIN ANALYZE first to confirm the query pattern before optimizing.

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 and have a rollback plan.

Should I use UUID or auto-increment primary keys?

Use UUID for distributed systems and security-sensitive contexts, ULID when you need time-sortable identifiers, and auto-increment for simple single-database apps. Natural keys with business meaning are rarely recommended.