databases
Design schemas, write queries for MongoDB and PostgreSQL. Use for database design, SQL/NoSQL queries, aggregation pipelines, indexes, migrations, replication, performance optimization, psql CLI.
- License 许可
- MIT
- 最近更新
- 2026-11-11
- Stars
- ★ 2
- Forks
- 1
01 前言 Front Matter
- name
- databases
- license
- MIT
- description
- Design schemas, write queries for MongoDB and PostgreSQL. Use for database design, SQL/NoSQL queries, aggregation pipelines, indexes, migrations, replication, performance optimization, psql CLI.
- argument-hint
- [query or schema task]
02 资源文件 29
- 其他.DS_Store6.0 KB
- 参考文档analytics.md5.3 KB
- 参考文档db-design.md6.3 KB
- 参考文档incremental-etl.md5.4 KB
- 参考文档references/mongodb-aggregation.md9.1 KB
- 参考文档references/mongodb-atlas.md9.1 KB
- 参考文档references/mongodb-crud.md8.2 KB
- 参考文档references/mongodb-indexing.md10.4 KB
- 参考文档references/postgresql-administration.md11.8 KB
- 参考文档references/postgresql-performance.md11.3 KB
- 参考文档references/postgresql-psql-cli.md10.3 KB
- 参考文档references/postgresql-queries.md9.9 KB
- 脚本scripts/.coverage52.0 KB
- 脚本scripts/.DS_Store6.0 KB
- 脚本scripts/db_backup.py16.4 KB
- 脚本scripts/db_migrate.py13.9 KB
- 脚本scripts/db_performance_check.py15.6 KB
- 脚本scripts/requirements.txt558 B
- 脚本scripts/tests/coverage-db.json46.3 KB
- 脚本scripts/tests/requirements.txt69 B
- 脚本scripts/tests/test_db_backup.py10.5 KB
- 脚本scripts/tests/test_db_migrate.py9.3 KB
- 脚本scripts/tests/test_db_performance_check.py11.7 KB
- 参考文档stacks/bigquery.md5.1 KB
- 参考文档stacks/d1_cloudflare.md3.4 KB
- 参考文档stacks/mysql.md5.5 KB
- 参考文档stacks/postgres.md5.8 KB
- 参考文档stacks/sqlite.md6.4 KB
- 参考文档transactional.md4.7 KB
03 SKILL.md 正文
Databases Skill
Unified guide for working with MongoDB (document-oriented) and PostgreSQL (relational) databases. Choose the right database for your use case and master both systems.
When to Use This Skill
Use when:
- Designing database schemas and data models
- Writing queries (SQL or MongoDB query language)
- Building aggregation pipelines or complex joins
- Optimizing indexes and query performance
- Implementing database migrations
- Setting up replication, sharding, or clustering
- Configuring backups and disaster recovery
- Managing database users and permissions
- Analyzing slow queries and performance issues
- Administering production database deployments
Reference Navigation
Database Design
- db-design.md - Activate when user requests: Database/table design for transactional (OLTP), analytics (OLAP), create or extend schema, design fact/dimension tables, analyze/review CSV/JSON/SQL files to create tables, or need advice on data storage structure.
MongoDB References
- mongodb-crud.md - CRUD operations, query operators, atomic updates
- mongodb-aggregation.md - Aggregation pipeline, stages, operators, patterns
- mongodb-indexing.md - Index types, compound indexes, performance optimization
- mongodb-atlas.md - Atlas cloud setup, clusters, monitoring, search
PostgreSQL References
- postgresql-queries.md - SELECT, JOINs, subqueries, CTEs, window functions
- postgresql-psql-cli.md - psql commands, meta-commands, scripting
- postgresql-performance.md - EXPLAIN, query optimization, vacuum, indexes
- postgresql-administration.md - User management, backups, replication, maintenance
Python Utilities
Database utility scripts in scripts/:
- db_migrate.py - Generate and apply migrations for both databases (MongoDB and PostgreSQL)
- db_backup.py - Backup and restore MongoDB and PostgreSQL
- db_performance_check.py - Analyze slow queries and recommend indexes
# Generate migration
python scripts/db_migrate.py --db mongodb --generate "add_user_index"
# Run backup
python scripts/db_backup.py --db postgres --output /backups/
# Check performance
python scripts/db_performance_check.py --db mongodb --threshold 100ms
Best Practices
MongoDB:
- Use embedded documents for 1-to-few relationships
- Reference documents for 1-to-many or many-to-many
- Index frequently queried fields
- Use aggregation pipeline for complex transformations
- Enable authentication and TLS in production
- Use Atlas for managed hosting
PostgreSQL:
- Normalize schema to 3NF, denormalize for performance
- Use foreign keys for referential integrity
- Index foreign keys and frequently filtered columns
- Use EXPLAIN ANALYZE to optimize queries
- Regular VACUUM and ANALYZE maintenance
- Connection pooling (pgBouncer) for web apps
Resources
- MongoDB: https://www.mongodb.com/docs/
- PostgreSQL: https://www.postgresql.org/docs/
- MongoDB University: https://learn.mongodb.com/
- PostgreSQL Tutorial: https://www.postgresqltutorial.com/
04 同仓库更多 Skills
web-testing
Web testing with Playwright, Vitest, k6. E2E/unit/integration/load/security/visual/a11y testing. Use for test automation, flakiness, Core Web Vitals, mobile gestures, cross-browser.
web-frameworks
Build with Next.js (App Router, RSC, SSR, ISR), Turborepo monorepos. Use for React apps, server rendering, build optimization, caching strategies, shared dependencies.
ui-styling
Style UIs with shadcn/ui components (Radix UI + Tailwind CSS). Use for accessible components, themes, dark mode, responsive layouts, design systems, color customization.
threejs
Build 3D web apps with Three.js (WebGL/WebGPU). 556 searchable examples, 60 API classes, 20 use cases. Actions: create 3D scene, load model, add animation, implement physics, build VR/XR. Topics: GLTF loader, PBR materials, particle effects, shadows, post-processing, compute shaders, TSL. Integrations: WebGPU, physics engines, spatial audio.
sequential-thinking
Apply step-by-step analysis for complex problems with revision capability. Use for multi-step reasoning, hypothesis verification, adaptive planning, problem decomposition, course correction.
research
Research technical solutions, analyze architectures, gather requirements thoroughly. Use for technology evaluation, best practices research, solution design, scalability/security/maintainability analysis.