Command Palette

Search for a command to run...

Назад к скиллам
скилл № 94153

data-relational-database

Use when the user asks about PostgreSQL or MySQL indexing, EXPLAIN ANALYZE, partitioning, streaming or logical replication, autovacuum, connection pooling…

БесплатноБез исполняемых скриптов
j4flmaoот j4flmao★ 47 звёзд на GitHub

Установить data-relational-database в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Об этом скилле

Data Relational Database

Purpose

Design relational database schemas with proper indexing, partitioning, replication, connection pooling, and query optimization strategies.

Agent Protocol

Trigger

Exact user phrases: "PostgreSQL", "MySQL", "relational database", "partitioning", "replication", "indexing", "vacuum", "connection pooling", "query optimization", "EXPLAIN", "CTE", "window function", "transaction isolation", "migration", "PgBouncer", "MVCC", "WAL", "B-tree", "GiST", "GIN", "BRIN".

Input Context

Before activating, verify:

  • Database platform (PostgreSQL, MySQL, MariaDB, SQLite)
  • Data volume (rows, growth rate, total size in GB/TB)
  • Query workload (OLTP, OLAP, mixed)
  • Current schema and migration tool (Alembic, Sqitch, Flyway, Liquibase)
  • Existing indexing strategy and planner statistics
  • Replication needs (read replicas, disaster recovery, logical replication)
  • Connection pooling requirements (client count, max connections)

Output Artifact

Database schema with indexes, partition configuration, replication setup, and query optimization plan as SQL and YAML.

Response Format

-- Table DDL with partitioning
-- Index creation statements
-- Replication configuration
-- Migration statements
# Connection pool config
# Replication setup
# Vacuum settings

No preamble. No postamble. No explanations. No filler/hedging/transitions. Compress output — why use many token when few do trick.

Completion Criteria

  • Normalized schema with appropriate constraints (PK, FK, CHECK, UNIQUE)
  • Indexing strategy covering slow queries (EXPLAIN ANALYZE output reviewed)
  • Partitioning scheme configured for large tables
  • Replication setup (streaming for HA, logical for data distribution)
  • Connection pool configured (PgBouncer transaction mode default)
  • Vacuum and autovacuum settings tuned
  • Transaction isolation levels chosen per workload
  • Migration plan with rollback strategy

Max Response Length

300 lines of SQL and configuration.

Workflow

Step 1: Schema Design

Normalize to 3NF by default. Denormalize only for read-heavy analytical queries. Every table needs a primary key (UUID or BIGSERIAL). Foreign keys with indexes on referencing columns. Naming: snake_case for tables, columns, indexes; uq_ unique, ix_ index, fk_ foreign key, pk_ primary key. Use CHECK constraints for domain integrity. Use ENUM or reference tables for constrained values.

CREATE TABLE customers (
    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    email TEXT NOT NULL UNIQUE,
    name TEXT NOT NULL,
    status customer_status NOT NULL DEFAULT 'active',
    created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
    updated_at TIMESTAMPTZ NOT NULL DEFAULT now()
);

Step 2: Indexing Strategy

B-tree: default for equality and range queries on high-cardinality columns. GiST: full-text search, geometric data, range type overlap. GIN: JSONB, array containment, full-text search tsvector. BRIN: large sequential tables where rows are physically ordered (time-series). Partial indexes for filtered queries. Composite indexes with leading column matching the most selective filter. Covering indexes (INCLUDE columns) for index-only scans. Avoid over-indexing on write-heavy tables.

-- B-tree composite: equality then range
CREATE INDEX ix_orders_customer_created
    ON orders (customer_id, created_at DESC);

-- Partial: only active orders
CREATE INDEX ix_orders_active
    ON orders (created_at DESC)
    WHERE status = 'pending';

-- GIN: JSONB path operations
CREATE INDEX ix_products_attrs
    ON products USING GIN (attributes jsonb_path_ops);

-- BRIN: time-series with 100000 block range
CREATE INDEX ix_events_ts
    ON events USING BRIN (occurred_at)
    WITH (pages_per_range = 100000);

Step 3: Partitioning

Range partition by date for time-series data. List partition by category/region. Hash partition for load balancing when no natural partition key. Sub-partitioning for multi-dimensional data. Each partition is a table — indexes must be created per partition or on parent (PG 12+). Partition pruning requires WHERE clause on partition key. Avoid too many partitions (>1000).

CREATE TABLE events (
    id BIGSERIAL, occurred_at TIMESTAMPTZ NOT NULL,
    event_type TEXT NOT NULL, payload JSONB
) PARTITION BY RANGE (occurred_at);

CREATE TABLE events_2025_q1 PARTITION OF events
    FOR VALUES FROM ('2025-01-01') TO ('2025-04-01');

CREATE TABLE events_2025_q2 PARTITION OF events
    FOR VALUES FROM ('2025-04-01') TO ('2025-07-01');

Step 4: Replication

Streaming replication: primary ships WAL to standbys. Synchronous for zero data loss (2 safe). Asynchronous for performance (slight lag). Cascading replication for geographic distribution. Logical replication: publish/subscribe at table level, cross-version compatible, supports selective replication. Conflict resolution for bidirectional: last-write-wins or custom handler.

Полный SKILL.md на GitHub

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

  • references/cockroachdb-yugabyte.md
  • references/database-indexing.md
  • references/database-migration-strategies.md
  • references/distributed-sql-databases.md
  • references/postgres-advanced.md
  • references/query-optimization.md
  • references/relational-database-high-availability.md
  • references/relational-database-query-optimization.md

FAQ

Что делает скилл data-relational-database?

Use when the user asks about PostgreSQL or MySQL indexing, EXPLAIN ANALYZE, partitioning, streaming or logical replication, autovacuum, connection pooling (PgBouncer) or query optimization. Produces index, partition, replication and pooling configs. Not for engine theory such as MVCC internals (use database-internals-mechanics) or sharding (use architecture-database-scaling).

Как установить скилл data-relational-database?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл data-relational-database запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить data-relational-database с