
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-codeInstalls 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 Case | Type | Avoid |
|---|---|---|
| Primary Key | UUID / BIGSERIAL | INT (range limits) |
| Timestamps | TIMESTAMPTZ | TIMESTAMP (no timezone) |
| Money | NUMERIC(19,4) | FLOAT (precision loss) |
| Status | TEXT + CHECK | INT (unreadable) |
| Semi-structured | JSONB | JSON (no indexing) |
| Full-text | TSVECTOR | LIKE '%..%' |
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