[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M75QFNDMGA8PJ6CE6E8FSC3N":3,"skill-same:01M75QFNDMGA8PJ6CE6E8FSC3N":105},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":21,"frontMatter":22,"refName":23,"commitSha":24,"skillDirectory":25,"forksCount":13,"repositoryHtmlUrl":26,"repositoryHomepageUrl":6,"ownerHtmlUrl":27,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":28,"install":29,"resources":42},"01M75QFNDMGA8PJ6CE6E8FSC3N","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.","TehutiRaEl\u002FTHEHIVE","TehutiRaEl","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F267495122?v=4","01M75N1QQQHT359S3XMYK7NPCB","01M75N1QRAW5P8P43HEHWMXCTE",0,"MIT","https:\u002F\u002Fgithub.com\u002FTehutiRaEl\u002FTHEHIVE\u002Fblob\u002Fmain\u002Fskills-library\u002Fengineering\u002Fskills\u002Fdatabase-designer\u002FSKILL.md",[],[],"2026-11-12 13:55:43",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","b4ebd6d8c3b36347a5d435bcb343a5fc1c6f08d1","skills-library\u002Fengineering\u002Fskills\u002Fdatabase-designer","https:\u002F\u002Fgithub.com\u002FTehutiRaEl\u002FTHEHIVE","https:\u002F\u002Fgithub.com\u002FTehutiRaEl","2026-11-15 04:00:21",{"source":8,"skillName":5,"commands":30,"prompt":40,"zipAvailable":41},[31,34,37],{"tool":32,"command":33},"npx","npx skills add TehutiRaEl\u002FTHEHIVE --skill database-designer",{"tool":35,"command":36},"bunx","bunx skills add TehutiRaEl\u002FTHEHIVE --skill database-designer",{"tool":38,"command":39},"pnpm","pnpm dlx skills add TehutiRaEl\u002FTHEHIVE --skill database-designer","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FTehutiRaEl\u002FTHEHIVE\u002Fblob\u002Fmain\u002Fskills-library\u002Fengineering\u002Fskills\u002Fdatabase-designer\u002FSKILL.md",true,[43,49,53,57,63,67,71,77,81,85,89,93,97,101],{"path":44,"resourceType":45,"resourceTypeDesc":46,"sizeBytes":47,"sourceHtmlUrl":48},"assets\u002Fsample_query_patterns.json","ASSET","资产文件",9244,"https:\u002F\u002Fgithub.com\u002FTehutiRaEl\u002FTHEHIVE\u002Fblob\u002Fmain\u002Fskills-library\u002Fengineering\u002Fskills\u002Fdatabase-designer\u002Fassets\u002Fsample_query_patterns.json",{"path":50,"resourceType":45,"resourceTypeDesc":46,"sizeBytes":51,"sourceHtmlUrl":52},"assets\u002Fsample_schema.json",9365,"https:\u002F\u002Fgithub.com\u002FTehutiRaEl\u002FTHEHIVE\u002Fblob\u002Fmain\u002Fskills-library\u002Fengineering\u002Fskills\u002Fdatabase-designer\u002Fassets\u002Fsample_schema.json",{"path":54,"resourceType":45,"resourceTypeDesc":46,"sizeBytes":55,"sourceHtmlUrl":56},"assets\u002Fsample_schema.sql",8301,"https:\u002F\u002Fgithub.com\u002FTehutiRaEl\u002FTHEHIVE\u002Fblob\u002Fmain\u002Fskills-library\u002Fengineering\u002Fskills\u002Fdatabase-designer\u002Fassets\u002Fsample_schema.sql",{"path":58,"resourceType":59,"resourceTypeDesc":60,"sizeBytes":61,"sourceHtmlUrl":62},"expected_outputs\u002Findex_optimization_sample.txt","REFERENCE","参考文档",2639,"https:\u002F\u002Fgithub.com\u002FTehutiRaEl\u002FTHEHIVE\u002Fblob\u002Fmain\u002Fskills-library\u002Fengineering\u002Fskills\u002Fdatabase-designer\u002Fexpected_outputs\u002Findex_optimization_sample.txt",{"path":64,"resourceType":59,"resourceTypeDesc":60,"sizeBytes":65,"sourceHtmlUrl":66},"expected_outputs\u002Fmigration_sample.txt",4509,"https:\u002F\u002Fgithub.com\u002FTehutiRaEl\u002FTHEHIVE\u002Fblob\u002Fmain\u002Fskills-library\u002Fengineering\u002Fskills\u002Fdatabase-designer\u002Fexpected_outputs\u002Fmigration_sample.txt",{"path":68,"resourceType":59,"resourceTypeDesc":60,"sizeBytes":69,"sourceHtmlUrl":70},"expected_outputs\u002Fschema_analysis_sample.txt",7474,"https:\u002F\u002Fgithub.com\u002FTehutiRaEl\u002FTHEHIVE\u002Fblob\u002Fmain\u002Fskills-library\u002Fengineering\u002Fskills\u002Fdatabase-designer\u002Fexpected_outputs\u002Fschema_analysis_sample.txt",{"path":72,"resourceType":73,"resourceTypeDesc":74,"sizeBytes":75,"sourceHtmlUrl":76},"index_optimizer.py","SCRIPT","脚本",38896,"https:\u002F\u002Fgithub.com\u002FTehutiRaEl\u002FTHEHIVE\u002Fblob\u002Fmain\u002Fskills-library\u002Fengineering\u002Fskills\u002Fdatabase-designer\u002Findex_optimizer.py",{"path":78,"resourceType":73,"resourceTypeDesc":74,"sizeBytes":79,"sourceHtmlUrl":80},"migration_generator.py",50373,"https:\u002F\u002Fgithub.com\u002FTehutiRaEl\u002FTHEHIVE\u002Fblob\u002Fmain\u002Fskills-library\u002Fengineering\u002Fskills\u002Fdatabase-designer\u002Fmigration_generator.py",{"path":82,"resourceType":59,"resourceTypeDesc":60,"sizeBytes":83,"sourceHtmlUrl":84},"README.md",11966,"https:\u002F\u002Fgithub.com\u002FTehutiRaEl\u002FTHEHIVE\u002Fblob\u002Fmain\u002Fskills-library\u002Fengineering\u002Fskills\u002Fdatabase-designer\u002FREADME.md",{"path":86,"resourceType":59,"resourceTypeDesc":60,"sizeBytes":87,"sourceHtmlUrl":88},"references\u002Fdatabase_selection_decision_tree.md",16344,"https:\u002F\u002Fgithub.com\u002FTehutiRaEl\u002FTHEHIVE\u002Fblob\u002Fmain\u002Fskills-library\u002Fengineering\u002Fskills\u002Fdatabase-designer\u002Freferences\u002Fdatabase_selection_decision_tree.md",{"path":90,"resourceType":59,"resourceTypeDesc":60,"sizeBytes":91,"sourceHtmlUrl":92},"references\u002Fdatabase-design-reference.md",14014,"https:\u002F\u002Fgithub.com\u002FTehutiRaEl\u002FTHEHIVE\u002Fblob\u002Fmain\u002Fskills-library\u002Fengineering\u002Fskills\u002Fdatabase-designer\u002Freferences\u002Fdatabase-design-reference.md",{"path":94,"resourceType":59,"resourceTypeDesc":60,"sizeBytes":95,"sourceHtmlUrl":96},"references\u002Findex_strategy_patterns.md",11831,"https:\u002F\u002Fgithub.com\u002FTehutiRaEl\u002FTHEHIVE\u002Fblob\u002Fmain\u002Fskills-library\u002Fengineering\u002Fskills\u002Fdatabase-designer\u002Freferences\u002Findex_strategy_patterns.md",{"path":98,"resourceType":59,"resourceTypeDesc":60,"sizeBytes":99,"sourceHtmlUrl":100},"references\u002Fnormalization_guide.md",10672,"https:\u002F\u002Fgithub.com\u002FTehutiRaEl\u002FTHEHIVE\u002Fblob\u002Fmain\u002Fskills-library\u002Fengineering\u002Fskills\u002Fdatabase-designer\u002Freferences\u002Fnormalization_guide.md",{"path":102,"resourceType":73,"resourceTypeDesc":74,"sizeBytes":103,"sourceHtmlUrl":104},"schema_analyzer.py",42034,"https:\u002F\u002Fgithub.com\u002FTehutiRaEl\u002FTHEHIVE\u002Fblob\u002Fmain\u002Fskills-library\u002Fengineering\u002Fskills\u002Fdatabase-designer\u002Fschema_analyzer.py",[106,113,119,126,133,140],{"skillNo":107,"name":108,"nameZh":6,"description":109,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":110,"categories":111,"keywords":112,"publishedAt":18},"01M76XP63XDM4PFPX8MMVYN9JX","preamble-gate","Use BEFORE doing any work in this repo — before the first file edit, commit, push, PR, branch operation, workflow dispatch, scheduled trigger or timer, agent\u002Fsubagent spawn, dependency install, or message sent to an outside service. Forces a plain-language preamble to the founder first: WHAT you are about to do, WHY, HOW, why it is NECESSARY, the PROJECTED IMPROVEMENT, and the COST and RISK — then, for consequential work (governance, security, money, CI\u002Ftriggers, rewriting history, multi-agent fan-out), waits for an explicit go-ahead. Read-only investigation (reading files, grep, git log\u002Fdiff, answering questions) is exempt. Applies to every AI that works in this repo, not just Claude. Founder rule, 2026-11-10, written after an unattended automation ran up cost and froze the hive. Not a substitute for wired-or-not (which governs how completion is CLAIMED); this governs what happens BEFORE work starts.","https:\u002F\u002Fgithub.com\u002FTehutiRaEl\u002FTHEHIVE\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fpreamble-gate\u002FSKILL.md",[],[],{"skillNo":114,"name":115,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":116,"categories":117,"keywords":118,"publishedAt":18},"01M75RAYXC1W361YR9NBXD59AM","visionary-recommender","https:\u002F\u002Fgithub.com\u002FTehutiRaEl\u002FTHEHIVE\u002Fblob\u002Fmain\u002Fskills\u002Fvisionary-recommender\u002FSKILL.md",[],[],{"skillNo":120,"name":121,"nameZh":6,"description":122,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":123,"categories":124,"keywords":125,"publishedAt":18},"01M75RAQN9Q450RD57J2S6FSR4","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\u002FTehutiRaEl\u002FTHEHIVE\u002Fblob\u002Fmain\u002Fskills-library\u002Fresearch\u002Fsyllabus\u002Fskills\u002Fsyllabus\u002FSKILL.md",[],[],{"skillNo":127,"name":128,"nameZh":6,"description":129,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":130,"categories":131,"keywords":132,"publishedAt":18},"01M75RAG1XMCJMF30HFV5S79AK","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\u002FTehutiRaEl\u002FTHEHIVE\u002Fblob\u002Fmain\u002Fskills-library\u002Fresearch\u002Fresearch\u002Fskills\u002Fresearch\u002FSKILL.md",[],[],{"skillNo":134,"name":135,"nameZh":6,"description":136,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":137,"categories":138,"keywords":139,"publishedAt":18},"01M75RA8RK2JVWB8MYGRB65V75","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\u002FTehutiRaEl\u002FTHEHIVE\u002Fblob\u002Fmain\u002Fskills-library\u002Fresearch\u002Fpulse\u002Fskills\u002Fpulse\u002FSKILL.md",[],[],{"skillNo":141,"name":142,"nameZh":6,"description":143,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":144,"categories":145,"keywords":146,"publishedAt":18},"01M75RA08RXYRFSTNC6EEEX4ZD","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\u002FTehutiRaEl\u002FTHEHIVE\u002Fblob\u002Fmain\u002Fskills-library\u002Fresearch\u002Fpatent\u002Fskills\u002Fpatent\u002FSKILL.md",[],[]]