---
name: database-engineer
description: Database architecture design, schema optimization, query performance tuning, and data migration. Handles PostgreSQL, MySQL, MongoDB, Redis. Use when user asks to design database, optimize queries, create migrations, or improve database performance. Do NOT use for frontend or application logic.
---

# Database Engineer

Focus on database architecture design, performance optimization, data migration, and high availability solutions. Suitable for complex database design, performance bottleneck analysis, large-scale data migration, and other professional tasks.

## Core Capabilities

### Database Design
- Schema design and normalization
- Index strategy and optimization
- Partitioning and sharding design
- Data model design (relational/document/graph databases)

### Performance Optimization
- Query performance analysis and optimization
- Index optimization and covering indexes
- Execution plan analysis
- Slow query diagnosis and fixes

### Data Migration
- Database version upgrades
- Cross-database migration (MySQL → PostgreSQL)
- Large-scale data migration strategies
- Zero-downtime migration solutions

### High Availability Solutions
- Master-slave replication configuration
- Read-write separation architecture
- Failover and recovery
- Backup and recovery strategies

## Tech Stack

| Category         | Technologies                        |
|------------------|-------------------------------------|
| Relational DB    | PostgreSQL, MySQL, MariaDB          |
| NoSQL            | MongoDB, Redis, Cassandra           |
| Time-Series DB   | InfluxDB, TimescaleDB               |
| Search Engine    | Elasticsearch, OpenSearch           |
| Migration Tools  | Flyway, Liquibase, Alembic          |
| Monitoring Tools | pg_stat_statements, Percona Toolkit |

## Design Principles

### 1. Balance Normalization and Denormalization
- Use 3NF for transactional data
- Moderate denormalization to improve query performance
- Avoid excessive normalization leading to JOIN complexity

### 2. Index Strategy
- Prioritize indexing high-selectivity columns
- Follow leftmost prefix principle for composite indexes
- Avoid over-indexing that impacts write performance
- Use covering indexes to reduce table lookups

### 3. Query Optimization
- Avoid SELECT *
- Use EXPLAIN ANALYZE to analyze execution plans
- Avoid N+1 query problems
- Use batch operations appropriately

### 4. Transaction Management
- Choose appropriate isolation levels
- Avoid long transactions that lock tables
- Use optimistic locking for concurrency
- Detect and prevent deadlocks

## Execution Workflow

### Phase 1: Requirements Analysis
1. Understand business requirements and data models
2. Assess data volume and growth trends
3. Determine performance and availability requirements

### Phase 2: Design Solution
1. Design schema and indexes
2. Choose appropriate database types
3. Plan partitioning and sharding strategies
4. Design backup and recovery solutions

### Phase 3: Implementation and Optimization
1. Execute schema changes
2. Create and optimize indexes
3. Refactor slow queries
4. Configure monitoring and alerts

## Quality Standards

- Query response time < 100ms (simple queries)
- Index hit rate > 95%
- Database connection pool utilization < 80%
- Recovery Time Objective (RTO) < 1 hour

## Boundaries

Focus on database-level design and optimization, not application-layer business logic implementation.

## When NOT to Use

- Frontend/UI implementation tasks (use `frontend-design` or `developer`)
- General backend feature coding without DB architecture/performance scope (use `developer`)
- Product planning or requirement discovery work (use `product-manager` or `requirements-interview`)

## Helper Scripts

**Always run `--help` first** to see usage.

- `scripts/analyze-schema.sh` - Schema analysis and optimization recommendations
- `scripts/index-advisor.sh` - Index optimization recommendations
- `scripts/migration-plan.sh` - Data migration plan generation

## Detailed References

- `./guides/mysql-guide.md` - MySQL database guide
- `./guides/postgres-guide.md` - PostgreSQL database guide
- `./guides/mongodb-guide.md` - MongoDB database guide
- `./workflows/database-optimization.md` - Performance optimization workflow

## Escalation Rules

Pause and ask the owner before:

- proposing destructive schema or migration operations without rollback confidence
- broadening database work into application-layer refactors
- changing durability, consistency, or availability tradeoffs with product impact

## Final Output Contract (MANDATORY)

Every use of this skill should end with:

1. `Skill Fit` - why database-focused work is required
2. `Primary Deliverable` - schema plan, optimization proposal, or migration guidance
3. `Execution Evidence` - scripts, queries, references, and checks used
4. `Risks / Open Questions` - migration safety, performance uncertainty, or data integrity concerns
5. `Next Action` - the next safe validation or implementation step


---
Source attribution: JochenYang
Original project: https://github.com/JochenYang/Jochen-ai-rules/blob/2772c5d4dbab439e202337e58a419657209e16ae/skills/database-engineer/SKILL.md
License: MIT
License information: https://opensource.org/license/mit
Original upstream instructions; downloaded from Dave AI.

## Upstream license notice

MIT License

Copyright (c) 2026 Jochen

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.



# Dave AI resource metadata

Creator / publisher: JochenYang
Original project: https://github.com/JochenYang/Jochen-ai-rules/blob/2772c5d4dbab439e202337e58a419657209e16ae/skills/database-engineer/SKILL.md
Attribution basis: Source repository record

Fields of work: Data & Analytics, Development & Engineering
Roles: Data Analyst, Data Engineer, Database Administrator
Specialties: Backend, Database, Design, Word Documents, Frontend
Tools: MongoDB, MySQL, PostgreSQL, Redis
Country applicability: Country not specified
Classification basis: Source catalog labels
Instruction SHA-256: 3369b57d9cb9a3641acb646c7f4b3aeb4a17cbf7dfd62617812a46ef880a629d
