Database Design

Codify database schema conventions, migration rules, and data integrity checks.

121|29|Updated Apr 12, 2026
One-click install
npx skills add https://github.com/KbWen/agentic-os --skill database-design-kbwen
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: Database Design
Source: https://github.com/KbWen/agentic-os/tree/main/.agents/skills/database-design
Command: npx skills add https://github.com/KbWen/agentic-os --skill database-design-kbwen

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill guides teams to design robust, scalable database schemas by codifying naming conventions, migration rules, and data-integrity constraints to prevent drift and regressions.

Core Features & Use Cases

  • Table Design: Every table MUST have: id (primary key), created_at, updated_at; ensure consistent UUIDs or auto-incremented IDs; support soft-delete via deleted_at when ADR requires it; use plural table names and snake_case column naming.
  • Relationship Patterns: One-to-Many, Many-to-Many, One-to-One, and Self-referencing relationships with clear foreign-key usage and indexing strategies.
  • Index Strategy & Data Integrity: Always index foreign keys; optimize for frequent WHERE clauses; use appropriate NOT NULL and CHECK constraints; avoid over-indexing.
  • Migration Rules: One migration per logical change; migrations MUST be reversible (up/down); keep schema changes separate from data migrations; validate rollback.
  • Query & Data Practices: Prefer parameterized queries; avoid SELECT *; apply consistent data types and defaults to ensure data quality.
  • Use Case: When starting a project, apply these conventions to produce a coherent, maintainable schema with safe, auditable migrations.

Quick Start

Apply these conventions at project start to align tables, relationships, and migrations with ADR-driven standards.

Frequently Asked Questions about Database Design

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

FAQPage Schema
What are the best practices for database schema design and migration rules?

Database schema design best practices require every table to have id, created_at, and updated_at columns, use plural snake_case naming, and enforce one reversible migration per logical change to prevent drift.

How do I design database tables with proper foreign key indexing and data integrity constraints?

Design database tables with proper foreign key indexing by always indexing foreign keys, applying NOT NULL and CHECK constraints for data integrity, and optimizing indexes for frequent WHERE clauses to avoid over-indexing.

How do I manage reversible database migrations for schema changes and data migrations?

Manage reversible database migrations by keeping schema changes separate from data migrations, ensuring each migration has up/down rollback capabilities, and validating rollback procedures to maintain auditable schema changes.

When should I use soft-delete and self-referential relationship patterns in database architecture?

Use soft-delete via a deleted_at column when architecture decision records require it, and apply self-referential relationship patterns with clear foreign-key usage when modeling hierarchical data structures within a single table.

Does database design governance work for feature development and data-related hotfix scenarios?

Database design governance works across feature development, architecture changes, and data-related hotfix scenarios by codifying table design rules, relationship patterns, and indexing guidelines during plan, implement, review, and test phases.

What query practices ensure data quality when designing scalable database schemas?

Query practices that ensure data quality include preferring parameterized queries, avoiding SELECT *, and applying consistent data types and defaults to maintain coherent, maintainable schemas across the project.