discover-database

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Database Skills Discovery

数据库技能发现

Provides automatic access to comprehensive database design, optimization, and implementation skills.
提供对全面的数据库设计、优化与实施技能的自动访问权限。

When This Skill Activates

本技能激活场景

This skill auto-activates when you're working with:
  • SQL databases (PostgreSQL, MySQL)
  • NoSQL databases (MongoDB, Redis)
  • Database schema design and modeling
  • Query optimization and performance tuning
  • Database migrations and schema evolution
  • Connection pooling configuration
  • ORM usage and patterns
  • Database selection and architecture decisions
当你处理以下内容时,本技能会自动激活:
  • SQL数据库(PostgreSQL、MySQL)
  • NoSQL数据库(MongoDB、Redis)
  • 数据库架构设计与建模
  • 查询优化与性能调优
  • 数据库迁移与架构演进
  • 连接池配置
  • ORM使用与模式
  • 数据库选型与架构决策

Available Skills

可用技能

Quick Reference

快速参考

The Database category contains 8 core skills:
  1. postgres-schema-design - Schema design, relationships, data types, normalization
  2. postgres-query-optimization - EXPLAIN plans, indexes, slow query debugging
  3. postgres-migrations - Schema changes, zero-downtime, rollback strategies
  4. mongodb-document-design - Document modeling, embedding vs referencing
  5. redis-data-structures - Caching, sessions, rate limiting, leaderboards
  6. database-connection-pooling - Pool configuration, debugging exhaustion
  7. orm-patterns - ORM best practices, N+1 prevention, eager loading
  8. database-selection - Choosing databases, SQL vs NoSQL decisions
数据库类别包含8项核心技能:
  1. postgres-schema-design - 架构设计、关系、数据类型、规范化
  2. postgres-query-optimization - EXPLAIN计划、索引、慢查询调试
  3. postgres-migrations - 架构变更、零停机、回滚策略
  4. mongodb-document-design - 文档建模、嵌入与引用对比
  5. redis-data-structures - 缓存、会话、限流、排行榜
  6. database-connection-pooling - 池配置、耗尽问题调试
  7. orm-patterns - ORM最佳实践、N+1问题预防、预加载
  8. database-selection - 数据库选型、SQL与NoSQL决策

Load Full Category Details

加载完整类别详情

For complete descriptions and workflows:
Read <cc-polymath-root>/skills/database/INDEX.md
This loads the full Database category index with:
  • Detailed skill descriptions
  • Usage triggers for each skill
  • Common workflow combinations
  • Cross-references to related skills
如需完整描述与工作流:
Read <cc-polymath-root>/skills/database/INDEX.md
这会加载完整的数据库类别索引,包含:
  • 详细的技能描述
  • 各项技能的触发场景
  • 常见工作流组合
  • 相关技能的交叉引用

Load Specific Skills

加载特定技能

Load individual skills as needed:
根据需要加载单个技能:

PostgreSQL skills

PostgreSQL技能

Read <cc-polymath-root>/skills/database/postgres-schema-design.md Read <cc-polymath-root>/skills/database/postgres-query-optimization.md Read <cc-polymath-root>/skills/database/postgres-migrations.md
Read <cc-polymath-root>/skills/database/postgres-schema-design.md Read <cc-polymath-root>/skills/database/postgres-query-optimization.md Read <cc-polymath-root>/skills/database/postgres-migrations.md

NoSQL skills

NoSQL技能

Read <cc-polymath-root>/skills/database/mongodb-document-design.md Read <cc-polymath-root>/skills/database/redis-data-structures.md
Read <cc-polymath-root>/skills/database/mongodb-document-design.md Read <cc-polymath-root>/skills/database/redis-data-structures.md

Cross-database skills

跨数据库技能

Read <cc-polymath-root>/skills/database/database-connection-pooling.md Read <cc-polymath-root>/skills/database/orm-patterns.md Read <cc-polymath-root>/skills/database/database-selection.md
Read <cc-polymath-root>/skills/database/database-connection-pooling.md Read <cc-polymath-root>/skills/database/orm-patterns.md Read <cc-polymath-root>/skills/database/database-selection.md

Common Workflows

常见工作流

New Database Project

新数据库项目

Sequence: Selection → Schema design → Connection pooling
Read <cc-polymath-root>/skills/database/database-selection.md # Choose database Read <cc-polymath-root>/skills/database/postgres-schema-design.md # or mongodb-document-design.md Read <cc-polymath-root>/skills/database/database-connection-pooling.md
流程:选型 → 架构设计 → 连接池配置
Read <cc-polymath-root>/skills/database/database-selection.md # 选择数据库 Read <cc-polymath-root>/skills/database/postgres-schema-design.md # 或 mongodb-document-design.md Read <cc-polymath-root>/skills/database/database-connection-pooling.md

Query Performance Debugging

查询性能调试

Sequence: Optimization → Connection pooling → ORM patterns
Read <cc-polymath-root>/skills/database/postgres-query-optimization.md # Debug slow queries Read <cc-polymath-root>/skills/database/database-connection-pooling.md # Check pool settings Read <cc-polymath-root>/skills/database/orm-patterns.md # Fix N+1 queries
流程:优化 → 连接池配置 → ORM模式
Read <cc-polymath-root>/skills/database/postgres-query-optimization.md # 调试慢查询 Read <cc-polymath-root>/skills/database/database-connection-pooling.md # 检查池配置 Read <cc-polymath-root>/skills/database/orm-patterns.md # 修复N+1查询

Schema Evolution

架构演进

Sequence: Schema design → Migrations
Read <cc-polymath-root>/skills/database/postgres-schema-design.md # Design changes Read <cc-polymath-root>/skills/database/postgres-migrations.md # Implement safely
流程:架构设计 → 迁移
Read <cc-polymath-root>/skills/database/postgres-schema-design.md # 设计变更 Read <cc-polymath-root>/skills/database/postgres-migrations.md # 安全实施

Caching Layer

缓存层

Sequence: Redis structures → Cache patterns
Read <cc-polymath-root>/skills/database/redis-data-structures.md # Redis patterns Then load caching skills via discover-caching gateway
流程:Redis数据结构 → 缓存模式
Read <cc-polymath-root>/skills/database/redis-data-structures.md # Redis模式 然后通过discover-caching网关加载缓存技能

Skill Selection Guide

技能选型指南

PostgreSQL skills (relational, ACID, complex queries):
  • postgres-schema-design.md
    - Design relational schemas
  • postgres-query-optimization.md
    - Optimize complex queries
  • postgres-migrations.md
    - Evolve schema over time
MongoDB skills (document-oriented, flexible schema):
  • mongodb-document-design.md
    - Design document structures
  • Choose when: Flexible schema, nested data, rapid iteration
Redis skills (in-memory, key-value, caching):
  • redis-data-structures.md
    - Caching, sessions, rate limiting
  • Choose when: Speed critical, caching layer, real-time features
Cross-database skills:
  • database-selection.md
    - Start here for new projects
  • database-connection-pooling.md
    - All databases need this
  • orm-patterns.md
    - When using ORMs (SQLAlchemy, Prisma, Mongoose)
PostgreSQL技能(关系型、ACID、复杂查询):
  • postgres-schema-design.md
    - 设计关系型架构
  • postgres-query-optimization.md
    - 优化复杂查询
  • postgres-migrations.md
    - 随时间演进架构
MongoDB技能(文档型、灵活架构):
  • mongodb-document-design.md
    - 设计文档结构
  • 适用场景:灵活架构、嵌套数据、快速迭代
Redis技能(内存型、键值对、缓存):
  • redis-data-structures.md
    - 缓存、会话、限流
  • 适用场景:对速度要求极高、缓存层、实时功能
跨数据库技能
  • database-selection.md
    - 新项目从这里开始
  • database-connection-pooling.md
    - 所有数据库都需要此项
  • orm-patterns.md
    - 使用ORM时(SQLAlchemy、Prisma、Mongoose)

Integration with Other Skills

与其他技能的集成

Database skills commonly combine with:
API skills (
discover-api
):
  • API endpoints → Database queries
  • Connection pooling for API servers
  • Query optimization for API performance
  • Migrations alongside API versioning
Backend language skills (
discover-backend
):
  • Python: SQLAlchemy, psycopg2, PyMongo
  • Zig: PostgreSQL C bindings
  • Rust: SQLx, Diesel
  • Go: database/sql, GORM
Testing skills (
discover-testing
):
  • Integration tests with test databases
  • Migration testing
  • Query performance testing
  • Data fixture management
Data pipeline skills (
discover-data
):
  • ETL from databases
  • Database as data source
  • Bulk data operations
  • Streaming database changes (CDC)
Observability skills (
discover-observability
):
  • Query metrics and slow query logs
  • Connection pool metrics
  • Database performance monitoring
  • Alert configuration
数据库技能通常与以下技能结合使用:
API技能 (
discover-api
):
  • API端点 → 数据库查询
  • API服务器的连接池
  • 针对API性能的查询优化
  • 与API版本管理同步的迁移
后端语言技能 (
discover-backend
):
  • Python:SQLAlchemy、psycopg2、PyMongo
  • Zig:PostgreSQL C绑定
  • Rust:SQLx、Diesel
  • Go:database/sql、GORM
测试技能 (
discover-testing
):
  • 测试数据库的集成测试
  • 迁移测试
  • 查询性能测试
  • 数据夹具管理
数据管道技能 (
discover-data
):
  • 从数据库提取、转换、加载(ETL)
  • 作为数据源的数据库
  • 批量数据操作
  • 数据库变更流(CDC)
可观测性技能 (
discover-observability
):
  • 查询指标与慢查询日志
  • 连接池指标
  • 数据库性能监控
  • 告警配置

Progressive Loading

渐进式加载

This gateway skill (~200 lines, ~2K tokens) enables progressive loading:
  • Level 1: Gateway loads automatically (you're here now)
  • Level 2: Load category INDEX.md (~3K tokens) for full overview
  • Level 3: Load specific skills (~2-4K tokens each) as needed
Total context: 2K + 3K + skill(s) = 5-10K tokens vs 25K+ for entire index.
此网关技能(约200行,约2K tokens)支持渐进式加载:
  • Level 1:网关自动加载(当前页面)
  • Level 2:加载类别INDEX.md(约3K tokens)获取完整概述
  • Level 3:根据需要加载特定技能(每个约2-4K tokens)
总上下文:2K + 3K + 技能 = 5-10K tokens,相比整个索引的25K+ tokens更轻量化。

Quick Start Examples

快速入门示例

"Design a PostgreSQL schema for an e-commerce app": Read <cc-polymath-root>/skills/database/postgres-schema-design.md
"Why is my query slow?": Read <cc-polymath-root>/skills/database/postgres-query-optimization.md
"How do I safely change my database schema?": Read <cc-polymath-root>/skills/database/postgres-migrations.md
"Should I use MongoDB or PostgreSQL?": Read <cc-polymath-root>/skills/database/database-selection.md
"Implement caching with Redis": Read <cc-polymath-root>/skills/database/redis-data-structures.md
"Fix N+1 queries in my ORM": Read <cc-polymath-root>/skills/database/orm-patterns.md
"为电商应用设计PostgreSQL架构": Read <cc-polymath-root>/skills/database/postgres-schema-design.md
"我的查询为什么慢?": Read <cc-polymath-root>/skills/database/postgres-query-optimization.md
"如何安全地修改数据库架构?": Read <cc-polymath-root>/skills/database/postgres-migrations.md
"我应该用MongoDB还是PostgreSQL?": Read <cc-polymath-root>/skills/database/database-selection.md
"用Redis实现缓存": Read <cc-polymath-root>/skills/database/redis-data-structures.md
"修复我的ORM中的N+1查询问题": Read <cc-polymath-root>/skills/database/orm-patterns.md

Database Type Decision Tree

数据库类型决策树

Need ACID transactions? YES → PostgreSQL
Need complex queries/joins? YES → PostgreSQL
Need flexible schema? YES → MongoDB
Need real-time caching? YES → Redis
Need full-text search? YES → PostgreSQL (with extensions) or Elasticsearch
Need graph relationships? YES → Neo4j or PostgreSQL (with extensions)
Need analytics? YES → DuckDB or Redpanda + Iceberg
For detailed decision-making: Read <cc-polymath-root>/skills/database/database-selection.md
Need ACID transactions? YES → PostgreSQL
Need complex queries/joins? YES → PostgreSQL
Need flexible schema? YES → MongoDB
Need real-time caching? YES → Redis
Need full-text search? YES → PostgreSQL (with extensions) or Elasticsearch
Need graph relationships? YES → Neo4j or PostgreSQL (with extensions)
Need analytics? YES → DuckDB or Redpanda + Iceberg
如需详细决策指导: Read <cc-polymath-root>/skills/database/database-selection.md

PostgreSQL Focus Areas

PostgreSQL重点领域

Schema design
postgres-schema-design.md
:
  • Tables, columns, data types
  • Primary keys, foreign keys, constraints
  • Normalization vs denormalization
  • Indexing strategies
Query optimization
postgres-query-optimization.md
:
  • EXPLAIN and EXPLAIN ANALYZE
  • Index selection and creation
  • Query plan analysis
  • Performance tuning
Migrations
postgres-migrations.md
:
  • Schema change strategies
  • Zero-downtime deployments
  • Rollback procedures
  • Migration tools (Alembic, Flyway, migrate)
架构设计
postgres-schema-design.md
  • 表、列、数据类型
  • 主键、外键、约束
  • 规范化与反规范化
  • 索引策略
查询优化
postgres-query-optimization.md
  • EXPLAIN与EXPLAIN ANALYZE
  • 索引选择与创建
  • 查询计划分析
  • 性能调优
迁移
postgres-migrations.md
  • 架构变更策略
  • 零停机部署
  • 回滚流程
  • 迁移工具(Alembic、Flyway、migrate)

NoSQL Focus Areas

NoSQL重点领域

MongoDB
mongodb-document-design.md
:
  • Document structure and embedding
  • References vs embedding tradeoffs
  • Schema versioning
  • Index design for documents
Redis
redis-data-structures.md
:
  • Strings, hashes, lists, sets, sorted sets
  • Caching patterns and TTLs
  • Session storage
  • Rate limiting implementations
  • Leaderboards and counters
MongoDB
mongodb-document-design.md
  • 文档结构与嵌入
  • 引用与嵌入的权衡
  • 架构版本控制
  • 文档索引设计
Redis
redis-data-structures.md
  • 字符串、哈希、列表、集合、有序集合
  • 缓存模式与TTL
  • 会话存储
  • 限流实现
  • 排行榜与计数器

ORM Considerations

ORM注意事项

Before using ORMs, load: Read <cc-polymath-root>/skills/database/orm-patterns.md
Common ORM pitfalls:
  • N+1 query problems
  • Lazy vs eager loading confusion
  • Transaction management
  • Raw SQL when necessary
  • Migration generation
Supported ORMs:
  • SQLAlchemy (Python)
  • Prisma (TypeScript/Node.js)
  • Diesel (Rust)
  • GORM (Go)
  • ActiveRecord (Ruby)
  • Entity Framework (C#)
使用ORM之前,请加载: Read <cc-polymath-root>/skills/database/orm-patterns.md
常见ORM陷阱
  • N+1查询问题
  • 延迟加载与预加载混淆
  • 事务管理
  • 必要时使用原生SQL
  • 迁移生成
支持的ORM
  • SQLAlchemy(Python)
  • Prisma(TypeScript/Node.js)
  • Diesel(Rust)
  • GORM(Go)
  • ActiveRecord(Ruby)
  • Entity Framework(C#)

Usage Instructions

使用说明

  1. Auto-activation: This skill loads automatically when Claude Code detects database work
  2. Browse skills: Run
    Read <cc-polymath-root>/skills/database/INDEX.md
    for full category overview
  3. Load specific skills: Use bash commands above to load individual skills
  4. Follow workflows: Use recommended sequences for common patterns
  5. Decision support: Start with
    database-selection.md
    for new projects
Next Steps: Run
Read <cc-polymath-root>/skills/database/INDEX.md
to see full category details, or load specific skills using the bash commands above.
  1. 自动激活:当Claude Code检测到数据库相关工作时,本技能会自动加载
  2. 浏览技能:运行
    Read <cc-polymath-root>/skills/database/INDEX.md
    获取完整类别概述
  3. 加载特定技能:使用上述bash命令加载单个技能
  4. 遵循工作流:针对常见模式使用推荐的流程
  5. 决策支持:新项目从
    database-selection.md
    开始
下一步:运行
Read <cc-polymath-root>/skills/database/INDEX.md
查看完整类别详情,或使用上述bash命令加载特定技能。