majiayu000 avatar

Database Patterns

This is a reference guide for PostgreSQL and Redis patterns you'd actually use in production. It covers the practical stuff: when to use JSONB versus proper columns, how to set up composite indexes that follow the leftmost prefix rule, cache-aside with stampede prevention, and TTL strategies for different data types. The code examples are concrete, like using NUMERIC(19,4) for money instead of floats, or caching null results to prevent penetration attacks. It takes opinionated stances (UUIDs over integers, no backward compatibility) which saves you from bikeshedding. Good for anyone building systems where caching strategy matters and you need to know whether a GIN index or expression index makes more sense for your JSONB queries.

skills.sh installs
119
GitHub stars
153
last updated
Jun 3, 2026

Install

$ npx -y skills add majiayu000/claude-arsenal --skill database-patterns --agent claude-code

Installs into .claude/skills of the current project.

Files

Database Patterns

Core Principles

  • PostgreSQL Primary — Relational data, transactions, complex queries
  • Redis Secondary — Caching, sessions, real-time data
  • Index-First Design — Design queries before indexes
  • JSONB Sparingly — Structured data prefers columns
  • Cache-Aside Default — Read-through, write-around
  • Tiered Storage — Hot/Warm/Cold data separation
  • No backwards compatibility — Migrate data, don't keep legacy schemas

PostgreSQL

Data Type Selection

Use CaseTypeAvoid
Primary KeyUUID / BIGSERIALINT (range limits)
TimestampsTIMESTAMPTZTIMESTAMP (no timezone)
MoneyNUMERIC(19,4)FLOAT (precision loss)
StatusTEXT + CHECKINT (unreadable)
Semi-structuredJSONBJSON (no indexing)
Full-textTSVECTORLIKE '%..%'

Schema Design

-- Use UUID for distributed-friendly IDs
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";

Sponsors

Details

Repository
github.com/majiayu000/claude-arsenal
Categories
Backend & APIs, Databases
First seen
Jun 3, 2026

More from majiayu000/claude-arsenal

All 8
1erichowens avatarmodern-auth-2026erichowens/some_claude_skillsmodern auth 2026115skills.sh installs
2bankrbot avatarBankr Agent - LLM Gatewaybankrbot/claude-pluginsThis skill should be used when the user asks about "LLM gateway", "Bankr LLM", "LLM credits", "top up credits", "auto top-up", "llm.bankr.bot", "Claude Code gat0skills.sh installs
3claude-office-skills avatarDatabase Syncclaude-office-skills/skillsAutomate database synchronization, replication, migration, and cross-platform data integration0skills.sh installs
4davila7 avatarSQLMap Database Penetration Testingdavila7/claude-code-templatesThis skill should be used when the user asks to "automate SQL injection testing," "enumerate database structure," "extract database credentials using sqlmap," "0skills.sh installs
5laolaoshiren avatarapi-testerlaolaoshiren/claude-code-skills-zhAPI 自动化测试 - OpenAPI 解析、测试用例生成、集成测试0skills.sh installs
6lawless-m avatarReverse Proxy Deploymentlawless-m/claude-skillsDeploy web applications behind Apache reverse proxy on rivsprod01 with relative URLs and proper path configuration0skills.sh installs