database-management-patterns
БесплатноБез исполняемых скриптовНе проверенComprehensive guide for database management patterns covering PostgreSQL and MongoDB including schema design, indexing, transactions, replication, and…
Об этом скилле
Database Management Patterns
A comprehensive skill for mastering database management across SQL (PostgreSQL) and NoSQL (MongoDB) systems. This skill covers schema design, indexing strategies, transaction management, replication, sharding, and performance optimization for production-grade applications.
When to Use This Skill
Use this skill when:
- Designing database schemas for new applications or refactoring existing ones
- Choosing between SQL and NoSQL databases for your use case
- Optimizing query performance with proper indexing strategies
- Implementing data consistency with transactions and ACID guarantees
- Scaling databases horizontally with sharding and replication
- Managing high-traffic applications requiring distributed databases
- Ensuring data integrity with constraints, triggers, and validation
- Troubleshooting performance issues using explain plans and query analysis
- Building fault-tolerant systems with replication and failover strategies
- Working with complex data relationships (relational) or flexible schemas (document)
Core Concepts
Database Paradigms Comparison
Relational Databases (PostgreSQL)
Strengths:
- ACID Transactions: Strong consistency guarantees
- Complex Queries: JOIN operations, subqueries, CTEs
- Data Integrity: Foreign keys, constraints, triggers
- Normalized Data: Reduced redundancy, consistent updates
- Mature Ecosystem: Rich tooling, extensions, community
Best For:
- Financial systems requiring strict consistency
- Complex relationships and data integrity requirements
- Applications with structured, well-defined schemas
- Systems requiring complex analytical queries
- Multi-step transactions across multiple tables
Document Databases (MongoDB)
Strengths:
- Flexible Schema: Easy schema evolution, polymorphic data
- Horizontal Scalability: Built-in sharding support
- JSON-Native: Natural fit for modern application development
- Embedded Documents: Denormalized data for performance
- Aggregation Framework: Powerful data processing pipeline
Best For:
- Rapidly evolving applications with changing requirements
- Content management systems with varied data structures
- Real-time analytics and event logging
- Mobile and web applications with JSON APIs
- Hierarchical or nested data structures
ACID Properties
Atomicity: All operations in a transaction succeed or fail together Consistency: Transactions bring database from one valid state to another Isolation: Concurrent transactions don't interfere with each other Durability: Committed transactions survive system failures
CAP Theorem
In distributed systems, choose two of three:
- Consistency: All nodes see the same data
- Availability: System remains operational
- Partition Tolerance: System continues despite network failures
PostgreSQL emphasizes CP (Consistency + Partition Tolerance) MongoDB can be configured for CP or AP depending on write/read concerns
PostgreSQL Patterns
Schema Design Fundamentals
Normalization Levels
First Normal Form (1NF)
- Atomic values (no arrays or lists in columns)
- Each row is unique (primary key exists)
- No repeating groups
Second Normal Form (2NF)
- Meets 1NF requirements
- All non-key attributes depend on the entire primary key
Third Normal Form (3NF)
- Meets 2NF requirements
- No transitive dependencies (non-key attributes depend only on primary key)
When to Denormalize:
- Read-heavy workloads where joins are expensive
- Frequently accessed aggregate data
- Historical snapshots that shouldn't change
- Performance-critical queries
Table Design Patterns
Primary Keys:
-- Serial auto-increment (traditional)
CREATE TABLE users (
id SERIAL PRIMARY KEY,
email VARCHAR(255) UNIQUE NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- UUID for distributed systems
CREATE TABLE accounts (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
name VARCHAR(255) NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- Composite primary key
CREATE TABLE order_items (
order_id INTEGER NOT NULL,
product_id INTEGER NOT NULL,
quantity INTEGER NOT NULL,
price NUMERIC(10, 2) NOT NULL,
PRIMARY KEY (order_id, product_id),
FOREIGN KEY (order_id) REFERENCES orders(id),
FOREIGN KEY (product_id) REFERENCES products(id)
);
Foreign Key Constraints:
-- Cascade delete: Remove child records when parent deleted
CREATE TABLE posts (
id SERIAL PRIMARY KEY,
user_id INTEGER NOT NULL,
title VARCHAR(255) NOT NULL,
content TEXT,
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
);
-- Set null: Preserve child records, nullify reference
CREATE TABLE comments (
id SERIAL PRIMARY KEY,
post_id INTEGER,
user_id INTEGER,
content TEXT NOT NULL,
FOREIGN KEY (post_id) REFERENCES posts(id) ON DELE
Установить database-management-patterns в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл database-management-patterns?
Comprehensive guide for database management patterns covering PostgreSQL and MongoDB including schema design, indexing, transactions, replication, and performance tuning
Как установить скилл database-management-patterns?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл database-management-patterns запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
frontend-design
Guidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making…
от Anthropicwebapp-testing
Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing…
от Anthropicbrand-guidelines
Applies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand…
от Anthropicweb-artifacts-builder
Suite of tools for creating elaborate, multi-component claude.ai HTML artifacts using modern frontend web technologies (React, Tailwind CSS, shadcn/ui). Use…
от Anthropic