database-design

Guides database schema design, indexing, migrations, and ORM selection for SQL and NoSQL systems.

Updated Apr 4, 2026
One-click install
npx skills add https://github.com/juanjo-zurich/juarvis-v4 --skill database-design-juanjo-zurich
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: database-design
Source: https://github.com/juanjo-zurich/juarvis-v4/tree/main/plugins/database/skills/database-design
Command: npx skills add https://github.com/juanjo-zurich/juarvis-v4 --skill database-design-juanjo-zurich

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Designing a database schema involves many decisions—SQL vs NoSQL, normalization, indexing, migrations, and ORM choice—where mistakes lead to slow queries, data integrity issues, and painful refactors. This Skill provides concrete rules and code patterns to make those decisions correctly from the start. ## Core Features & Use Cases - SQL vs NoSQL Selection: Decision criteria for PostgreSQL, MongoDB, Redis, Elasticsearch, and other engines based on data shape and access patterns. - Schema & Index Design: Normalization examples, correct data types (NUMERIC for money, TIMESTAMPTZ, JSONB), constraints, and indexing strategies including partial and composite indexes. - Migrations & ORM Guidance: Zero-downtime migration patterns with Alembic and Prisma, plus an ORM comparison table (SQLAlchemy, Prisma, Drizzle, TypeORM, Django ORM). - Use Case: When a query is slow or you suspect an N+1 problem, apply the eager-loading patterns (e.g., SQLAlchemy joinedload) and foreign-key indexing rules to fix it. ## Quick Start Ask the AI to design a normalized PostgreSQL schema with proper indexes and constraints for your application's data model.

Frequently Asked Questions about database-design

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

FAQPage Schema
How do I design a normalized database schema in PostgreSQL?▼

Normalize by extracting repeated data into separate tables referenced by foreign keys, such as users and products tables referenced from orders. Always add NOT NULL, UNIQUE, CHECK constraints, and defaults at the database level rather than only in application code.

When should I use SQL vs NoSQL for my database?▼

Use SQL like PostgreSQL for relational data, ACID transactions, complex JOINs, and reporting. Use NoSQL for schemaless documents (MongoDB), caching (Redis), time-series, full-text search (Elasticsearch), or graphs (Neo4j). Start with PostgreSQL and add NoSQL only for specific use cases.

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

Fix N+1 queries by using eager loading with joinedload, for example session.query(Order).options(joinedload(Order.user)).all(). This loads related objects in a single query instead of issuing one query per iteration.

Prisma vs SQLAlchemy vs Drizzle: which ORM should I choose?▼

SQLAlchemy 2 suits complex Python applications needing fine control, Prisma offers type-safe queries and strong developer experience in TypeScript, Drizzle is lightweight and SQL-like for Edge environments, and Django ORM fits Django projects.

How do I run zero-downtime database migrations?▼

Add new columns as nullable first, backfill existing data, then apply NOT NULL constraints after deployment. Never edit existing migrations; make each migration reversible with a down migration using Alembic or Prisma migrate.

Why shouldn't I index every column in my database?▼

Each index slows down write operations because it must be updated on every insert or update. Index only foreign keys, frequently searched columns, and use partial or composite indexes for common filtered queries.