[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7ARBADF9N5XATXTJF08R1BA":3,"skill-same:01M7ARBADF9N5XATXTJF08R1BA":107},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":14,"repositoryHtmlUrl":27,"repositoryHomepageUrl":6,"ownerHtmlUrl":28,"ownerBlogUrl":6,"ownerDescription":29,"updatedAt":30,"install":31,"resources":44},"01M7ARBADF9N5XATXTJF08R1BA","database-designer",null,"Use when the user asks to design database schemas, plan data migrations, optimize queries, choose between SQL and NoSQL, or model data relationships.","GongYuanCaiJi\u002Fdsh-claude-skills","GongYuanCaiJi","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F129952120?v=4","01M7AK39Q4W3VPF7C1K8M58BFX","劉昱廷 Yu-Ting Liu","01M7APPQ7AEZTDQB0N6HCPTR2X",0,"MIT","https:\u002F\u002Fgithub.com\u002FGongYuanCaiJi\u002Fdsh-claude-skills\u002Fblob\u002Fmain\u002Fengineering\u002Fskills\u002Fdatabase-designer\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: \"database-designer\"\ndescription: \"Use when the user asks to design database schemas, plan data migrations, optimize queries, choose between SQL and NoSQL, or model data relationships.\"\n---\n\n# Database Designer - POWERFUL Tier Skill\n\n## Overview\n\nA comprehensive database design skill that provides expert-level analysis, optimization, and migration capabilities for modern database systems. This skill combines theoretical principles with practical tools to help architects and developers create scalable, performant, and maintainable database schemas.\n\n## Core Competencies\n\n### Schema Design & Analysis\n- **Normalization Analysis**: Automated detection of normalization levels (1NF through BCNF)\n- **Denormalization Strategy**: Smart recommendations for performance optimization\n- **Data Type Optimization**: Identification of inappropriate types and size issues\n- **Constraint Analysis**: Missing foreign keys, unique constraints, and null checks\n- **Naming Convention Validation**: Consistent table and column naming patterns\n- **ERD Generation**: Automatic Mermaid diagram creation from DDL\n\n### Index Optimization\n- **Index Gap Analysis**: Identification of missing indexes on foreign keys and query patterns\n- **Composite Index Strategy**: Optimal column ordering for multi-column indexes\n- **Index Redundancy Detection**: Elimination of overlapping and unused indexes\n- **Performance Impact Modeling**: Selectivity estimation and query cost analysis\n- **Index Type Selection**: B-tree, hash, partial, covering, and specialized indexes\n\n### Migration Management\n- **Zero-Downtime Migrations**: Expand-contract pattern implementation\n- **Schema Evolution**: Safe column additions, deletions, and type changes\n- **Data Migration Scripts**: Automated data transformation and validation\n- **Rollback Strategy**: Complete reversal capabilities with validation\n- **Execution Planning**: Ordered migration steps with dependency resolution\n\n## Tool Workflow (run these — do not analyze schemas by hand)\n\nAll paths relative to this skill folder; sample inputs in `assets\u002F`.\n\n### 1. Analyze the schema\n\n```bash\npython3 schema_analyzer.py --input schema.sql --generate-erd --output-format json -o analysis.json\n```\n\nAccepts SQL DDL or JSON schema (`assets\u002Fsample_schema.sql` \u002F `sample_schema.json`). Output includes normalization findings, missing constraints, naming issues, and a Mermaid ERD — show the ERD to the user and fix flagged issues before optimizing.\n\n### 2. Optimize indexes against real query patterns\n\n```bash\npython3 index_optimizer.py --schema assets\u002Fsample_schema.json --queries assets\u002Fsample_query_patterns.json --analyze-existing --format json -o indexes.json\n```\n\nWrite the user's hot queries into a query-patterns JSON first (copy `assets\u002Fsample_query_patterns.json`). Output is a priority-ordered list of CREATE INDEX recommendations plus redundant-index removals.\n\n### 3. Generate the migration\n\n```bash\npython3 migration_generator.py --current current_schema.json --target target_schema.json --zero-downtime --format sql -o migration.sql\n```\n\n`--zero-downtime` emits an expand-contract plan; `--validate-only` checks feasibility without generating SQL.\n\n### 4. Verification loop\n\nRe-run step 1 on the *target* schema and assert the issues found in the first pass are gone; run `migration_generator.py --validate-only` before handing over the migration.\n\n## Database Design Principles\n→ See references\u002Fdatabase-design-reference.md for details\n\n## Best Practices\n\n### Schema Design\n1. **Use meaningful names**: Clear, consistent naming conventions\n2. **Choose appropriate data types**: Right-sized columns for storage efficiency\n3. **Define proper constraints**: Foreign keys, check constraints, unique indexes\n4. **Consider future growth**: Plan for scale from the beginning\n5. **Document relationships**: Clear foreign key relationships and business rules\n\n### Performance Optimization\n1. **Index strategically**: Cover common query patterns without over-indexing\n2. **Monitor query performance**: Regular analysis of slow queries\n3. **Partition large tables**: Improve query performance and maintenance\n4. **Use appropriate isolation levels**: Balance consistency with performance\n5. **Implement connection pooling**: Efficient resource utilization\n\n### Security Considerations\n1. **Principle of least privilege**: Grant minimal necessary permissions\n2. **Encrypt sensitive data**: At rest and in transit\n3. **Audit access patterns**: Monitor and log database access\n4. **Validate inputs**: Prevent SQL injection attacks\n5. **Regular security updates**: Keep database software current\n\n## Query Generation Patterns\n\n### SELECT with JOINs\n\n```sql\n-- INNER JOIN: only matching rows\nSELECT o.id, c.name, o.total\nFROM orders o\nINNER JOIN customers c ON c.id = o.customer_id;\n\n-- LEFT JOIN: all left rows, NULLs for non-matches\nSELECT c.name, COUNT(o.id) AS order_count\nFROM customers c\nLEFT JOIN orders o ON o.customer_id = c.id\nGROUP BY c.name;\n\n-- Self-join: hierarchical data (employees\u002Fmanagers)\nSELECT e.name AS employee, m.name AS manager\nFROM employees e\nLEFT JOIN employees m ON m.id = e.manager_id;\n```\n\n### Common Table Expressions (CTEs)\n\n```sql\n-- Recursive CTE for org chart\nWITH RECURSIVE org AS (\n  SELECT id, name, manager_id, 1 AS depth\n  FROM employees WHERE manager_id IS NULL\n  UNION ALL\n  SELECT e.id, e.name, e.manager_id, o.depth + 1\n  FROM employees e INNER JOIN org o ON o.id = e.manager_id\n)\nSELECT * FROM org ORDER BY depth, name;\n```\n\n### Window Functions\n\n```sql\n-- ROW_NUMBER for pagination \u002F dedup\nSELECT *, ROW_NUMBER() OVER (PARTITION BY customer_id ORDER BY created_at DESC) AS rn\nFROM orders;\n\n-- RANK with gaps, DENSE_RANK without gaps\nSELECT name, score, RANK() OVER (ORDER BY score DESC) AS rank FROM leaderboard;\n\n-- LAG\u002FLEAD for comparing adjacent rows\nSELECT date, revenue,\n  revenue - LAG(revenue) OVER (ORDER BY date) AS daily_change\nFROM daily_sales;\n```\n\n### Aggregation Patterns\n\n```sql\n-- FILTER clause (PostgreSQL) for conditional aggregation\nSELECT\n  COUNT(*) AS total,\n  COUNT(*) FILTER (WHERE status = 'active') AS active,\n  AVG(amount) FILTER (WHERE amount > 0) AS avg_positive\nFROM accounts;\n\n-- GROUPING SETS for multi-level rollups\nSELECT region, product, SUM(revenue)\nFROM sales\nGROUP BY GROUPING SETS ((region, product), (region), ());\n```\n\n---\n\n## Migration Patterns\n\n### Up\u002FDown Migration Scripts\n\nEvery migration must have a reversible counterpart. Name files with a timestamp prefix for ordering:\n\n```\nmigrations\u002F\n├── 20260101_000001_create_users.up.sql\n├── 20260101_000001_create_users.down.sql\n├── 20260115_000002_add_users_email_index.up.sql\n└── 20260115_000002_add_users_email_index.down.sql\n```\n\n### Zero-Downtime Migrations (Expand\u002FContract)\n\nUse the expand-contract pattern to avoid locking or breaking running code:\n\n1. **Expand** — add the new column\u002Ftable (nullable, with default)\n2. **Migrate data** — backfill in batches; dual-write from application\n3. **Transition** — application reads from new column; stop writing to old\n4. **Contract** — drop old column in a follow-up migration\n\n### Data Backfill Strategies\n\n```sql\n-- Batch update to avoid long-running locks\nUPDATE users SET email_normalized = LOWER(email)\nWHERE id IN (SELECT id FROM users WHERE email_normalized IS NULL LIMIT 5000);\n-- Repeat in a loop until 0 rows affected\n```\n\n### Rollback Procedures\n\n- Always test the `down.sql` in staging before deploying `up.sql` to production\n- Keep rollback window short — if the contract step has run, rollback requires a new forward migration\n- For irreversible changes (dropping columns with data), take a logical backup first\n\n---\n\n## Performance Optimization\n\n### Indexing Strategies\n\n| Index Type | Use Case | Example |\n|------------|----------|---------|\n| **B-tree** (default) | Equality, range, ORDER BY | `CREATE INDEX idx_users_email ON users(email);` |\n| **GIN** | Full-text search, JSONB, arrays | `CREATE INDEX idx_docs_body ON docs USING gin(to_tsvector('english', body));` |\n| **GiST** | Geometry, range types, nearest-neighbor | `CREATE INDEX idx_locations ON places USING gist(coords);` |\n| **Partial** | Subset of rows (reduce size) | `CREATE INDEX idx_active ON users(email) WHERE active = true;` |\n| **Covering** | Index-only scans | `CREATE INDEX idx_cov ON orders(customer_id) INCLUDE (total, created_at);` |\n\n### EXPLAIN Plan Reading\n\n```sql\nEXPLAIN (ANALYZE, BUFFERS, FORMAT TEXT) SELECT ...;\n```\n\nKey signals to watch:\n- **Seq Scan** on large tables — missing index\n- **Nested Loop** with high row estimates — consider hash\u002Fmerge join or add index\n- **Buffers shared read** much higher than **hit** — working set exceeds memory\n\n### N+1 Query Detection\n\nSymptoms: application issues one query per row (e.g., fetching related records in a loop).\n\nFixes:\n- Use `JOIN` or subquery to fetch in one round-trip\n- ORM eager loading (`select_related` \u002F `includes` \u002F `with`)\n- DataLoader pattern for GraphQL resolvers\n\n### Connection Pooling\n\n| Tool | Protocol | Best For |\n|------|----------|----------|\n| **PgBouncer** | PostgreSQL | Transaction\u002Fstatement pooling, low overhead |\n| **ProxySQL** | MySQL | Query routing, read\u002Fwrite splitting |\n| **Built-in pool** (HikariCP, SQLAlchemy pool) | Any | Application-level pooling |\n\n**Rule of thumb:** Set pool size to `(2 * CPU cores) + disk spindles`. For cloud SSDs, start with `2 * vCPUs` and tune.\n\n### Read Replicas and Query Routing\n\n- Route all `SELECT` queries to replicas; writes to primary\n- Account for replication lag (typically \u003C1s for async, 0 for sync)\n- Use `pg_last_wal_replay_lsn()` to detect lag before reading critical data\n\n---\n\n## Multi-Database Decision Matrix\n\n| Criteria | PostgreSQL | MySQL | SQLite | SQL Server |\n|----------|-----------|-------|--------|------------|\n| **Best for** | Complex queries, JSONB, extensions | Web apps, read-heavy workloads | Embedded, dev\u002Ftest, edge | Enterprise .NET stacks |\n| **JSON support** | Excellent (JSONB + GIN) | Good (JSON type) | Minimal | Good (OPENJSON) |\n| **Replication** | Streaming, logical | Group replication, InnoDB cluster | N\u002FA | Always On AG |\n| **Licensing** | Open source (PostgreSQL License) | Open source (GPL) \u002F commercial | Public domain | Commercial |\n| **Max practical size** | Multi-TB | Multi-TB | ~1 TB (single-writer) | Multi-TB |\n\n**When to choose:**\n- **PostgreSQL** — default choice for new projects; best extensibility and standards compliance\n- **MySQL** — existing MySQL ecosystem; simple read-heavy web applications\n- **SQLite** — mobile apps, CLI tools, unit test databases, IoT\u002Fedge\n- **SQL Server** — mandated by enterprise policy; deep .NET\u002FAzure integration\n\n### NoSQL Considerations\n\n| Database | Model | Use When |\n|----------|-------|----------|\n| **MongoDB** | Document | Schema flexibility, rapid prototyping, content management |\n| **Redis** | Key-value \u002F cache | Session store, rate limiting, leaderboards, pub\u002Fsub |\n| **DynamoDB** | Wide-column | Serverless AWS apps, single-digit-ms latency at any scale |\n\n> Use SQL as default. Reach for NoSQL only when the access pattern clearly benefits from it.\n\n---\n\n## Sharding & Replication\n\n### Horizontal vs Vertical Partitioning\n\n- **Vertical partitioning**: Split columns across tables (e.g., separate BLOB columns). Reduces I\u002FO for narrow queries.\n- **Horizontal partitioning (sharding)**: Split rows across databases\u002Fservers. Required when a single node cannot hold the dataset or handle the throughput.\n\n### Sharding Strategies\n\n| Strategy | How It Works | Pros | Cons |\n|----------|-------------|------|------|\n| **Hash** | `shard = hash(key) % N` | Even distribution | Resharding is expensive |\n| **Range** | Shard by date or ID range | Simple, good for time-series | Hot spots on latest shard |\n| **Geographic** | Shard by user region | Data locality, compliance | Cross-region queries are hard |\n\n### Replication Patterns\n\n| Pattern | Consistency | Latency | Use Case |\n|---------|------------|---------|----------|\n| **Synchronous** | Strong | Higher write latency | Financial transactions |\n| **Asynchronous** | Eventual | Low write latency | Read-heavy web apps |\n| **Semi-synchronous** | At-least-one replica confirmed | Moderate | Balance of safety and speed |\n\n---\n\n## Cross-References\n\n- **sql-database-assistant** — query writing, optimization, and debugging for day-to-day SQL work\n- **database-schema-designer** — ERD modeling, normalization analysis, and schema generation\n- **migration-architect** — large-scale migration planning across database engines or major schema overhauls\n- **senior-backend** — application-layer patterns (connection pooling, ORM best practices)\n- **senior-devops** — infrastructure provisioning for database clusters and replicas\n\n","# Database Designer - POWERFUL Tier Skill\n\n## Overview\n\nA comprehensive database design skill that provides expert-level analysis, optimization, and migration capabilities for modern database systems. This skill combines theoretical principles with practical tools to help architects and developers create scalable, performant, and maintainable database schemas.\n\n## Core Competencies\n\n### Schema Design & Analysis\n- **Normalization Analysis**: Automated detection of normalization levels (1NF through BCNF)\n- **Denormalization Strategy**: Smart recommendations for performance optimization\n- **Data Type Optimization**: Identification of inappropriate types and size issues\n- **Constraint Analysis**: Missing foreign keys, unique constraints, and null checks\n- **Naming Convention Validation**: Consistent table and column naming patterns\n- **ERD Generation**: Automatic Mermaid diagram creation from DDL\n\n### Index Optimization\n- **Index Gap Analysis**: Identification of missing indexes on foreign keys and query patterns\n- **Composite Index Strategy**: Optimal column ordering for multi-column indexes\n- **Index Redundancy Detection**: Elimination of overlapping and unused indexes\n- **Performance Impact Modeling**: Selectivity estimation and query cost analysis\n- **Index Type Selection**: B-tree, hash, partial, covering, and specialized indexes\n\n### Migration Management\n- **Zero-Downtime Migrations**: Expand-contract pattern implementation\n- **Schema Evolution**: Safe column additions, deletions, and type changes\n- **Data Migration Scripts**: Automated data transformation and validation\n- **Rollback Strategy**: Complete reversal capabilities with validation\n- **Execution Planning**: Ordered migration steps with dependency resolution\n\n## Tool Workflow (run these — do not analyze schemas by hand)\n\nAll paths relative to this skill folder; sample inputs in `assets\u002F`.\n\n### 1. Analyze the schema\n\n```bash\npython3 schema_analyzer.py --input schema.sql --generate-erd --output-format json -o analysis.json\n```\n\nAccepts SQL DDL or JSON schema (`assets\u002Fsample_schema.sql` \u002F `sample_schema.json`). Output includes normalization findings, missing constraints, naming issues, and a Mermaid ERD — show the ERD to the user and fix flagged issues before optimizing.\n\n### 2. Optimize indexes against real query patterns\n\n```bash\npython3 index_optimizer.py --schema assets\u002Fsample_schema.json --queries assets\u002Fsample_query_patterns.json --analyze-existing --format json -o indexes.json\n```\n\nWrite the user's hot queries into a query-patterns JSON first (copy `assets\u002Fsample_query_patterns.json`). Output is a priority-ordered list of CREATE INDEX recommendations plus redundant-index removals.\n\n### 3. Generate the migration\n\n```bash\npython3 migration_generator.py --current current_schema.json --target target_schema.json --zero-downtime --format sql -o migration.sql\n```\n\n`--zero-downtime` emits an expand-contract plan; `--validate-only` checks feasibility without generating SQL.\n\n### 4. Verification loop\n\nRe-run step 1 on the *target* schema and assert the issues found in the first pass are gone; run `migration_generator.py --validate-only` before handing over the migration.\n\n## Database Design Principles\n→ See references\u002Fdatabase-design-reference.md for details\n\n## Best Practices\n\n### Schema Design\n1. **Use meaningful names**: Clear, consistent naming conventions\n2. **Choose appropriate data types**: Right-sized columns for storage efficiency\n3. **Define proper constraints**: Foreign keys, check constraints, unique indexes\n4. **Consider future growth**: Plan for scale from the beginning\n5. **Document relationships**: Clear foreign key relationships and business rules\n\n### Performance Optimization\n1. **Index strategically**: Cover common query patterns without over-indexing\n2. **Monitor query performance**: Regular analysis of slow queries\n3. **Partition large tables**: Improve query performance and maintenance\n4. **Use appropriate isolation levels**: Balance consistency with performance\n5. **Implement connection pooling**: Efficient resource utilization\n\n### Security Considerations\n1. **Principle of least privilege**: Grant minimal necessary permissions\n2. **Encrypt sensitive data**: At rest and in transit\n3. **Audit access patterns**: Monitor and log database access\n4. **Validate inputs**: Prevent SQL injection attacks\n5. **Regular security updates**: Keep database software current\n\n## Query Generation Patterns\n\n### SELECT with JOINs\n\n```sql\n-- INNER JOIN: only matching rows\nSELECT o.id, c.name, o.total\nFROM orders o\nINNER JOIN customers c ON c.id = o.customer_id;\n\n-- LEFT JOIN: all left rows, NULLs for non-matches\nSELECT c.name, COUNT(o.id) AS order_count\nFROM customers c\nLEFT JOIN orders o ON o.customer_id = c.id\nGROUP BY c.name;\n\n-- Self-join: hierarchical data (employees\u002Fmanagers)\nSELECT e.name AS employee, m.name AS manager\nFROM employees e\nLEFT JOIN employees m ON m.id = e.manager_id;\n```\n\n### Common Table Expressions (CTEs)\n\n```sql\n-- Recursive CTE for org chart\nWITH RECURSIVE org AS (\n  SELECT id, name, manager_id, 1 AS depth\n  FROM employees WHERE manager_id IS NULL\n  UNION ALL\n  SELECT e.id, e.name, e.manager_id, o.depth + 1\n  FROM employees e INNER JOIN org o ON o.id = e.manager_id\n)\nSELECT * FROM org ORDER BY depth, name;\n```\n\n### Window Functions\n\n```sql\n-- ROW_NUMBER for pagination \u002F dedup\nSELECT *, ROW_NUMBER() OVER (PARTITION BY customer_id ORDER BY created_at DESC) AS rn\nFROM orders;\n\n-- RANK with gaps, DENSE_RANK without gaps\nSELECT name, score, RANK() OVER (ORDER BY score DESC) AS rank FROM leaderboard;\n\n-- LAG\u002FLEAD for comparing adjacent rows\nSELECT date, revenue,\n  revenue - LAG(revenue) OVER (ORDER BY date) AS daily_change\nFROM daily_sales;\n```\n\n### Aggregation Patterns\n\n```sql\n-- FILTER clause (PostgreSQL) for conditional aggregation\nSELECT\n  COUNT(*) AS total,\n  COUNT(*) FILTER (WHERE status = 'active') AS active,\n  AVG(amount) FILTER (WHERE amount > 0) AS avg_positive\nFROM accounts;\n\n-- GROUPING SETS for multi-level rollups\nSELECT region, product, SUM(revenue)\nFROM sales\nGROUP BY GROUPING SETS ((region, product), (region), ());\n```\n\n---\n\n## Migration Patterns\n\n### Up\u002FDown Migration Scripts\n\nEvery migration must have a reversible counterpart. Name files with a timestamp prefix for ordering:\n\n```\nmigrations\u002F\n├── 20260101_000001_create_users.up.sql\n├── 20260101_000001_create_users.down.sql\n├── 20260115_000002_add_users_email_index.up.sql\n└── 20260115_000002_add_users_email_index.down.sql\n```\n\n### Zero-Downtime Migrations (Expand\u002FContract)\n\nUse the expand-contract pattern to avoid locking or breaking running code:\n\n1. **Expand** — add the new column\u002Ftable (nullable, with default)\n2. **Migrate data** — backfill in batches; dual-write from application\n3. **Transition** — application reads from new column; stop writing to old\n4. **Contract** — drop old column in a follow-up migration\n\n### Data Backfill Strategies\n\n```sql\n-- Batch update to avoid long-running locks\nUPDATE users SET email_normalized = LOWER(email)\nWHERE id IN (SELECT id FROM users WHERE email_normalized IS NULL LIMIT 5000);\n-- Repeat in a loop until 0 rows affected\n```\n\n### Rollback Procedures\n\n- Always test the `down.sql` in staging before deploying `up.sql` to production\n- Keep rollback window short — if the contract step has run, rollback requires a new forward migration\n- For irreversible changes (dropping columns with data), take a logical backup first\n\n---\n\n## Performance Optimization\n\n### Indexing Strategies\n\n| Index Type | Use Case | Example |\n|------------|----------|---------|\n| **B-tree** (default) | Equality, range, ORDER BY | `CREATE INDEX idx_users_email ON users(email);` |\n| **GIN** | Full-text search, JSONB, arrays | `CREATE INDEX idx_docs_body ON docs USING gin(to_tsvector('english', body));` |\n| **GiST** | Geometry, range types, nearest-neighbor | `CREATE INDEX idx_locations ON places USING gist(coords);` |\n| **Partial** | Subset of rows (reduce size) | `CREATE INDEX idx_active ON users(email) WHERE active = true;` |\n| **Covering** | Index-only scans | `CREATE INDEX idx_cov ON orders(customer_id) INCLUDE (total, created_at);` |\n\n### EXPLAIN Plan Reading\n\n```sql\nEXPLAIN (ANALYZE, BUFFERS, FORMAT TEXT) SELECT ...;\n```\n\nKey signals to watch:\n- **Seq Scan** on large tables — missing index\n- **Nested Loop** with high row estimates — consider hash\u002Fmerge join or add index\n- **Buffers shared read** much higher than **hit** — working set exceeds memory\n\n### N+1 Query Detection\n\nSymptoms: application issues one query per row (e.g., fetching related records in a loop).\n\nFixes:\n- Use `JOIN` or subquery to fetch in one round-trip\n- ORM eager loading (`select_related` \u002F `includes` \u002F `with`)\n- DataLoader pattern for GraphQL resolvers\n\n### Connection Pooling\n\n| Tool | Protocol | Best For |\n|------|----------|----------|\n| **PgBouncer** | PostgreSQL | Transaction\u002Fstatement pooling, low overhead |\n| **ProxySQL** | MySQL | Query routing, read\u002Fwrite splitting |\n| **Built-in pool** (HikariCP, SQLAlchemy pool) | Any | Application-level pooling |\n\n**Rule of thumb:** Set pool size to `(2 * CPU cores) + disk spindles`. For cloud SSDs, start with `2 * vCPUs` and tune.\n\n### Read Replicas and Query Routing\n\n- Route all `SELECT` queries to replicas; writes to primary\n- Account for replication lag (typically \u003C1s for async, 0 for sync)\n- Use `pg_last_wal_replay_lsn()` to detect lag before reading critical data\n\n---\n\n## Multi-Database Decision Matrix\n\n| Criteria | PostgreSQL | MySQL | SQLite | SQL Server |\n|----------|-----------|-------|--------|------------|\n| **Best for** | Complex queries, JSONB, extensions | Web apps, read-heavy workloads | Embedded, dev\u002Ftest, edge | Enterprise .NET stacks |\n| **JSON support** | Excellent (JSONB + GIN) | Good (JSON type) | Minimal | Good (OPENJSON) |\n| **Replication** | Streaming, logical | Group replication, InnoDB cluster | N\u002FA | Always On AG |\n| **Licensing** | Open source (PostgreSQL License) | Open source (GPL) \u002F commercial | Public domain | Commercial |\n| **Max practical size** | Multi-TB | Multi-TB | ~1 TB (single-writer) | Multi-TB |\n\n**When to choose:**\n- **PostgreSQL** — default choice for new projects; best extensibility and standards compliance\n- **MySQL** — existing MySQL ecosystem; simple read-heavy web applications\n- **SQLite** — mobile apps, CLI tools, unit test databases, IoT\u002Fedge\n- **SQL Server** — mandated by enterprise policy; deep .NET\u002FAzure integration\n\n### NoSQL Considerations\n\n| Database | Model | Use When |\n|----------|-------|----------|\n| **MongoDB** | Document | Schema flexibility, rapid prototyping, content management |\n| **Redis** | Key-value \u002F cache | Session store, rate limiting, leaderboards, pub\u002Fsub |\n| **DynamoDB** | Wide-column | Serverless AWS apps, single-digit-ms latency at any scale |\n\n> Use SQL as default. Reach for NoSQL only when the access pattern clearly benefits from it.\n\n---\n\n## Sharding & Replication\n\n### Horizontal vs Vertical Partitioning\n\n- **Vertical partitioning**: Split columns across tables (e.g., separate BLOB columns). Reduces I\u002FO for narrow queries.\n- **Horizontal partitioning (sharding)**: Split rows across databases\u002Fservers. Required when a single node cannot hold the dataset or handle the throughput.\n\n### Sharding Strategies\n\n| Strategy | How It Works | Pros | Cons |\n|----------|-------------|------|------|\n| **Hash** | `shard = hash(key) % N` | Even distribution | Resharding is expensive |\n| **Range** | Shard by date or ID range | Simple, good for time-series | Hot spots on latest shard |\n| **Geographic** | Shard by user region | Data locality, compliance | Cross-region queries are hard |\n\n### Replication Patterns\n\n| Pattern | Consistency | Latency | Use Case |\n|---------|------------|---------|----------|\n| **Synchronous** | Strong | Higher write latency | Financial transactions |\n| **Asynchronous** | Eventual | Low write latency | Read-heavy web apps |\n| **Semi-synchronous** | At-least-one replica confirmed | Moderate | Balance of safety and speed |\n\n---\n\n## Cross-References\n\n- **sql-database-assistant** — query writing, optimization, and debugging for day-to-day SQL work\n- **database-schema-designer** — ERD modeling, normalization analysis, and schema generation\n- **migration-architect** — large-scale migration planning across database engines or major schema overhauls\n- **senior-backend** — application-layer patterns (connection pooling, ORM best practices)\n- **senior-devops** — infrastructure provisioning for database clusters and replicas\n\n",{"name":5,"description":7},"main","992d25a425dee442a1f6a628d00a4fed33efe839","engineering\u002Fskills\u002Fdatabase-designer","https:\u002F\u002Fgithub.com\u002FGongYuanCaiJi\u002Fdsh-claude-skills","https:\u002F\u002Fgithub.com\u002FGongYuanCaiJi","漏洞研究、根因分析、黑箱測試｜做 AI agent 工具｜Vulnerability research, root-cause analysis, AI agent tooling","2026-08-16 04:26:20",{"source":8,"skillName":5,"commands":32,"prompt":42,"zipAvailable":43},[33,36,39],{"tool":34,"command":35},"npx","npx skills add GongYuanCaiJi\u002Fdsh-claude-skills --skill database-designer",{"tool":37,"command":38},"bunx","bunx skills add GongYuanCaiJi\u002Fdsh-claude-skills --skill database-designer",{"tool":40,"command":41},"pnpm","pnpm dlx skills add GongYuanCaiJi\u002Fdsh-claude-skills --skill database-designer","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FGongYuanCaiJi\u002Fdsh-claude-skills\u002Fblob\u002Fmain\u002Fengineering\u002Fskills\u002Fdatabase-designer\u002FSKILL.md",true,[45,51,55,59,65,69,73,79,83,87,91,95,99,103],{"path":46,"resourceType":47,"resourceTypeDesc":48,"sizeBytes":49,"sourceHtmlUrl":50},"assets\u002Fsample_query_patterns.json","ASSET","资产文件",9244,"https:\u002F\u002Fgithub.com\u002FGongYuanCaiJi\u002Fdsh-claude-skills\u002Fblob\u002Fmain\u002Fengineering\u002Fskills\u002Fdatabase-designer\u002Fassets\u002Fsample_query_patterns.json",{"path":52,"resourceType":47,"resourceTypeDesc":48,"sizeBytes":53,"sourceHtmlUrl":54},"assets\u002Fsample_schema.json",9365,"https:\u002F\u002Fgithub.com\u002FGongYuanCaiJi\u002Fdsh-claude-skills\u002Fblob\u002Fmain\u002Fengineering\u002Fskills\u002Fdatabase-designer\u002Fassets\u002Fsample_schema.json",{"path":56,"resourceType":47,"resourceTypeDesc":48,"sizeBytes":57,"sourceHtmlUrl":58},"assets\u002Fsample_schema.sql",8301,"https:\u002F\u002Fgithub.com\u002FGongYuanCaiJi\u002Fdsh-claude-skills\u002Fblob\u002Fmain\u002Fengineering\u002Fskills\u002Fdatabase-designer\u002Fassets\u002Fsample_schema.sql",{"path":60,"resourceType":61,"resourceTypeDesc":62,"sizeBytes":63,"sourceHtmlUrl":64},"expected_outputs\u002Findex_optimization_sample.txt","REFERENCE","参考文档",2639,"https:\u002F\u002Fgithub.com\u002FGongYuanCaiJi\u002Fdsh-claude-skills\u002Fblob\u002Fmain\u002Fengineering\u002Fskills\u002Fdatabase-designer\u002Fexpected_outputs\u002Findex_optimization_sample.txt",{"path":66,"resourceType":61,"resourceTypeDesc":62,"sizeBytes":67,"sourceHtmlUrl":68},"expected_outputs\u002Fmigration_sample.txt",4509,"https:\u002F\u002Fgithub.com\u002FGongYuanCaiJi\u002Fdsh-claude-skills\u002Fblob\u002Fmain\u002Fengineering\u002Fskills\u002Fdatabase-designer\u002Fexpected_outputs\u002Fmigration_sample.txt",{"path":70,"resourceType":61,"resourceTypeDesc":62,"sizeBytes":71,"sourceHtmlUrl":72},"expected_outputs\u002Fschema_analysis_sample.txt",7474,"https:\u002F\u002Fgithub.com\u002FGongYuanCaiJi\u002Fdsh-claude-skills\u002Fblob\u002Fmain\u002Fengineering\u002Fskills\u002Fdatabase-designer\u002Fexpected_outputs\u002Fschema_analysis_sample.txt",{"path":74,"resourceType":75,"resourceTypeDesc":76,"sizeBytes":77,"sourceHtmlUrl":78},"index_optimizer.py","SCRIPT","脚本",38896,"https:\u002F\u002Fgithub.com\u002FGongYuanCaiJi\u002Fdsh-claude-skills\u002Fblob\u002Fmain\u002Fengineering\u002Fskills\u002Fdatabase-designer\u002Findex_optimizer.py",{"path":80,"resourceType":75,"resourceTypeDesc":76,"sizeBytes":81,"sourceHtmlUrl":82},"migration_generator.py",50373,"https:\u002F\u002Fgithub.com\u002FGongYuanCaiJi\u002Fdsh-claude-skills\u002Fblob\u002Fmain\u002Fengineering\u002Fskills\u002Fdatabase-designer\u002Fmigration_generator.py",{"path":84,"resourceType":61,"resourceTypeDesc":62,"sizeBytes":85,"sourceHtmlUrl":86},"README.md",11966,"https:\u002F\u002Fgithub.com\u002FGongYuanCaiJi\u002Fdsh-claude-skills\u002Fblob\u002Fmain\u002Fengineering\u002Fskills\u002Fdatabase-designer\u002FREADME.md",{"path":88,"resourceType":61,"resourceTypeDesc":62,"sizeBytes":89,"sourceHtmlUrl":90},"references\u002Fdatabase_selection_decision_tree.md",16344,"https:\u002F\u002Fgithub.com\u002FGongYuanCaiJi\u002Fdsh-claude-skills\u002Fblob\u002Fmain\u002Fengineering\u002Fskills\u002Fdatabase-designer\u002Freferences\u002Fdatabase_selection_decision_tree.md",{"path":92,"resourceType":61,"resourceTypeDesc":62,"sizeBytes":93,"sourceHtmlUrl":94},"references\u002Fdatabase-design-reference.md",14014,"https:\u002F\u002Fgithub.com\u002FGongYuanCaiJi\u002Fdsh-claude-skills\u002Fblob\u002Fmain\u002Fengineering\u002Fskills\u002Fdatabase-designer\u002Freferences\u002Fdatabase-design-reference.md",{"path":96,"resourceType":61,"resourceTypeDesc":62,"sizeBytes":97,"sourceHtmlUrl":98},"references\u002Findex_strategy_patterns.md",11831,"https:\u002F\u002Fgithub.com\u002FGongYuanCaiJi\u002Fdsh-claude-skills\u002Fblob\u002Fmain\u002Fengineering\u002Fskills\u002Fdatabase-designer\u002Freferences\u002Findex_strategy_patterns.md",{"path":100,"resourceType":61,"resourceTypeDesc":62,"sizeBytes":101,"sourceHtmlUrl":102},"references\u002Fnormalization_guide.md",10672,"https:\u002F\u002Fgithub.com\u002FGongYuanCaiJi\u002Fdsh-claude-skills\u002Fblob\u002Fmain\u002Fengineering\u002Fskills\u002Fdatabase-designer\u002Freferences\u002Fnormalization_guide.md",{"path":104,"resourceType":75,"resourceTypeDesc":76,"sizeBytes":105,"sourceHtmlUrl":106},"schema_analyzer.py",42034,"https:\u002F\u002Fgithub.com\u002FGongYuanCaiJi\u002Fdsh-claude-skills\u002Fblob\u002Fmain\u002Fengineering\u002Fskills\u002Fdatabase-designer\u002Fschema_analyzer.py",[108,115,122,129,136,143],{"skillNo":109,"name":110,"nameZh":6,"description":111,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":112,"categories":113,"keywords":114,"publishedAt":19},"01M7ASG5XZVP67CMMRENYFQWPW","syllabus","Generates a curated supplementary reading list from any course syllabus using Consensus academic search. Grill-me intake (syllabus input format + course audience + year range) plus a grouping forcing-options checkpoint before any search runs — so the reading list matches the course's level and recency need. Parses the syllabus to extract topics and learning outcomes, searches Consensus for recent peer-reviewed papers per topic, and produces a professionally formatted .docx with clickable Consensus links, plain-language summaries calibrated to audience level, and Bloom-higher-order discussion questions tied to course learning goals. Use when the user uploads a syllabus, course outline, or curriculum document and wants supplementary readings (e.g., 'create a reading list from this syllabus', 'find recent papers for my course') — even casual mentions with a syllabus attached should trigger this skill.","https:\u002F\u002Fgithub.com\u002FGongYuanCaiJi\u002Fdsh-claude-skills\u002Fblob\u002Fmain\u002Fresearch\u002Fsyllabus\u002Fskills\u002Fsyllabus\u002FSKILL.md",[],[],{"skillNo":116,"name":117,"nameZh":6,"description":118,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":119,"categories":120,"keywords":121,"publishedAt":19},"01M7ASFSGJF6G9KM40S1QJPR57","research","Default entry point for any research request — a hybrid router that classifies the question deterministically and either delegates to a specialist research skill (pulse for trends\u002Fsentiment, grants for NIH funding, litreview for academic literature, syllabus for course reading, patent for prior-art + IP landscape, dossier for entity research) or runs its own plan-decompose-multi-source-search-synthesize-cite fallback workflow when no specialist matches. Always surfaces the routing decision so users can override. Use when the user makes any research request that doesn't obviously match a more-specific specialist skill (e.g., \"research [topic]\", \"look into [topic]\", \"what do we know about [topic]\", \"investigate [topic]\", \"find me information on [topic]\", \"do some research on [topic]\", \"I need to understand [topic]\"). Output is a markdown briefing (default) or .docx document (on request) with full citations and an audit log.","https:\u002F\u002Fgithub.com\u002FGongYuanCaiJi\u002Fdsh-claude-skills\u002Fblob\u002Fmain\u002Fresearch\u002Fresearch\u002Fskills\u002Fresearch\u002FSKILL.md",[],[],{"skillNo":123,"name":124,"nameZh":6,"description":125,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":126,"categories":127,"keywords":128,"publishedAt":19},"01M7ASFFNCMS1X5X276VE277KW","pulse","Multi-source recency research skill that takes the pulse of any topic across Reddit, Hacker News, the open web, and optionally X\u002FTwitter within a configurable recent window (default 30 days). Forcing intake clarifies topic specificity, angle (trend\u002Fsentiment\u002Fproblems\u002Fopportunities\u002Fcomparison), time window, and platform scope before searching. Returns a synthesized briefing with citations, engagement metrics, and cross-platform pattern analysis. Use when the user requests multi-source recency intelligence on a topic (e.g., 'pulse on [topic]', 'what's happening with [topic]', 'what are people saying about [topic]', 'current conversation about [topic]', 'take the pulse of [topic]', 'trending: [topic]', 'find me info on [topic]'), and for competitor research, trend discovery, tool comparisons, and audience sentiment analysis.","https:\u002F\u002Fgithub.com\u002FGongYuanCaiJi\u002Fdsh-claude-skills\u002Fblob\u002Fmain\u002Fresearch\u002Fpulse\u002Fskills\u002Fpulse\u002FSKILL.md",[],[],{"skillNo":130,"name":131,"nameZh":6,"description":132,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":133,"categories":134,"keywords":135,"publishedAt":19},"01M7ASF2BM8D9CDRQV1VBV7FV6","patent","Patent prior-art and landscape intelligence skill — not generic patent help. Commits to one of five sub-use-cases via forcing intake (novelty search \u002F freedom-to-operate \u002F competitive landscape \u002F acquisition diligence \u002F litigation prior-art) before any search runs. Searches Google Patents, Espacenet, USPTO, and optionally Lens.org for citation-graph signals. Output is an editable Word document (.docx) with verdict, ranked closest art (claim-text extracted), CPC-class-aware landscape, family-resolved hits, geographic coverage, FTO flags where applicable, strategy recommendations, and full audit log. Use when the user asks for patent searching or analysis (e.g., 'prior art search for [invention]', 'freedom to operate analysis for [product]'). Produces search signal, not legal advice — always recommends consulting a patent attorney before filing or licensing decisions. Trademark, copyright, and trade-secret questions are out of scope.","https:\u002F\u002Fgithub.com\u002FGongYuanCaiJi\u002Fdsh-claude-skills\u002Fblob\u002Fmain\u002Fresearch\u002Fpatent\u002Fskills\u002Fpatent\u002FSKILL.md",[],[],{"skillNo":137,"name":138,"nameZh":6,"description":139,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":140,"categories":141,"keywords":142,"publishedAt":19},"01M7ASERRV1ES4S7QJRTTYWK0H","notebooklm","Browser automation skill for controlling Google's NotebookLM. Use when the user wants anything done in NotebookLM (e.g., 'open NotebookLM', 'check my [name] notebook', 'ask my notebook about X', 'add [source] to NotebookLM', 'generate a Video Overview from my notebook', 'use NotebookLM Studio'). Handles reading and querying notebooks, adding sources (URLs, text, files, YouTube links, synthesized content), generating Studio outputs (Audio\u002FVideo Overviews, Mind Maps, Reports incl. Briefing Doc\u002FStudy Guide\u002FFAQ, Flashcards, Quiz, slide decks, infographics — discover the exact set from the live Studio panel; the UI evolves fast), and creating new notebooks. Requires browser automation environment — fails gracefully when unavailable.","https:\u002F\u002Fgithub.com\u002FGongYuanCaiJi\u002Fdsh-claude-skills\u002Fblob\u002Fmain\u002Fresearch\u002Fnotebooklm\u002Fskills\u002Fnotebooklm\u002FSKILL.md",[],[],{"skillNo":144,"name":145,"nameZh":6,"description":146,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":147,"categories":148,"keywords":149,"publishedAt":19},"01M7ASEANH3H547WQBZ7X8W5CX","litreview","Academic literature orientation skill that searches papers via free keyless APIs (PubMed E-utilities + OpenAlex) by default — with the Consensus MCP as an optional enhancement lane when connected — builds a strategic search plan using PICO (default) or SPIDER \u002F Decomposition \u002F hybrid as fallbacks, and synthesizes findings into a formatted Word (.docx) research guide. Grill-me intake (research question specificity + framework hint + tentative depth) before the recon search; a second forcing checkpoint after Phase 2 confirms framework + sub-areas + depth before searches consume budget. Configurable depth (5\u002F10\u002F20 queries) controls coverage vs. speed. Output is a 'launching pad' — an orientation guide that lets a researcher dive in confidently, not a finished review. Use when the user starts literature-oriented research (e.g., 'litreview on [topic]', 'literature review on [topic]', 'I'm starting a literature review on X', 'I'm writing a paper on X', 'help me research X', 'I'm doing research on X', 'can you help me research X'). Do NOT use for single one-off paper searches wanting a quick list — that's a plain PubMed\u002FOpenAlex (or Consensus) query.","https:\u002F\u002Fgithub.com\u002FGongYuanCaiJi\u002Fdsh-claude-skills\u002Fblob\u002Fmain\u002Fresearch\u002Flitreview\u002Fskills\u002Flitreview\u002FSKILL.md",[],[]]