agentsclimarketplace

Database patterns

Skill subhansh-dev/agent-maxxing/engineering/database-patterns

Database design patterns — schema design, indexing, migrations, query optimization.From its SKILL.md

Install
npx -y skills add subhansh-dev/agent-maxxing --skill database-patterns

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 2 stars2 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

SKILL.md

2.1 KB, 512 tokens by cl100k_base, as published. Nobody here has run it

Database Patterns

Schema Design

Naming

  • Tables: plural, snake_case (users, order_items)
  • Columns: snake_case (created_at, user_id)
  • Primary keys: id (auto-increment or UUID)
  • Foreign keys: <table>_id (user_id, order_id)
  • Timestamps: created_at, updated_at, deleted_at

Data Types

  • Strings: VARCHAR(n) for known max, TEXT for unlimited
  • Numbers: INTEGER for whole numbers, DECIMAL(p,s) for money
  • Booleans: BOOLEAN or TINYINT(1)
  • Dates: TIMESTAMP for date+time, DATE for date only
  • JSON: JSONB (PostgreSQL) for flexible structure

Relationships

  • One-to-many: foreign key on the many side
  • Many-to-many: junction table
  • One-to-one: foreign key with unique constraint

Indexing

When to Index

  • Columns used in WHERE clauses
  • Columns used in JOIN conditions
  • Columns used in ORDER BY
  • Columns with high cardinality (many unique values)

When NOT to Index

  • Small tables (< 1000 rows)
  • Columns with low cardinality (boolean, status)
  • Columns that are frequently updated
  • Tables with heavy write loads

Index Types

  • B-tree: default, good for most queries
  • Hash: exact match only, very fast
  • GIN: full-text search, JSON queries
  • Partial: index with WHERE clause

Migrations

Rules

  • Every migration must be reversible
  • Never modify a deployed migration
  • Add columns as nullable first, then backfill
  • Create index CONCURRENTLY in production
  • Test migrations on a copy of production data

Safe Migration Pattern

-- Step 1: Add nullable column
ALTER TABLE users ADD COLUMN bio TEXT;

-- Step 2: Backfill
UPDATE users SET bio = '' WHERE bio IS NULL;

-- Step 3: Add NOT NULL constraint
ALTER TABLE users ALTER COLUMN bio SET NOT NULL;

Query Optimization

  • Use EXPLAIN ANALYZE to check query plans
  • Avoid SELECT * — select only needed columns
  • Use LIMIT for large result sets
  • Batch inserts instead of single inserts
  • Use connection pooling
  • Avoid N+1 queries — use JOINs or eager loading

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.