Token导航 LogoToken导航TokenDH.com
研究检索只读github未标认证来源可访问clear审计未展示

database-schema-designer数据库模式设计器

Agent Skill

用于辅助数据库表结构、查询语句、迁移脚本和数据维护任务。它适合让 Agent 分析 schema、编写 SQL、排查查询问题、整理索引或生成迁移建议。使用时需要明确数据库类型、连接环境和目标表,区分只读分析与写入变更;涉及删除、更新、迁移和批量导入时,应优先 dry-run、备份或事务保护,避免误操作。

总安装

428

周安装

18

GitHub Stars

公开资料未说明

下载量

150
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

MIT

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:database-schema-designer(数据库模式设计器)
来源仓库:https://github.com/yonatangross/skillforge-claude-plugin
仓库路径:skills/database-schema-designer
安装命令:
npx skills add yonatangross/skillforge-claude-plugin --skill "database-schema-designer"
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

AgentSkills.tonpx skills
npx skills add yonatangross/skillforge-claude-plugin --skill "database-schema-designer"

简介

database-schema-designer 用于辅助数据库表结构、查询语句、迁移脚本和数据维护任务,适合让 Agent 分析 schema、编写 SQL、排查查询问题、整理索引或生成迁移建议。

  • 适用于数据库表结构设计、查询语句编写、迁移脚本和数据维护等场景。
  • 通过 npx skills add yonatangross/skillforge-claude-plugin --skill "database-schema-designer" 安装。
  • 使用时需要明确数据库类型、连接环境,区分只读分析与写入变更,涉及删除、更新、迁移时应优先 dry-run、备份或事务保护。
  • 适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。

SKILL.md

Database Schema Designer

This skill provides comprehensive guidance for designing robust, scalable database schemas for both SQL and NoSQL databases. Whether building from scratch or evolving existing schemas, this framework ensures data integrity, performance, and maintainability.

Overview

  • Designing new database schemas
  • Refactoring or migrating existing schemas
  • Optimizing database performance
  • Choosing between SQL and NoSQL approaches
  • Creating database migrations
  • Establishing indexing strategies
  • Modeling complex relationships
  • Planning data archival and partitioning

Database Design Philosophy

Core Principles

1. Model the Domain, Not the UI

  • Schema reflects business entities and relationships
  • Don't let UI requirements drive data structure
  • Separate presentation concerns from data model

2. Optimize for Reads or Writes (Not Both)

  • OLTP (transactional): Normalized, optimized for writes
  • OLAP (analytical): Denormalized, optimized for reads
  • Choose based on access patterns

3. Plan for Scale From Day One

  • Indexing strategy
  • Partitioning approach
  • Caching layer
  • Read replicas

4. Data Integrity Over Performance

  • Use constraints, foreign keys, validation
  • Performance issues can be optimized later
  • Data corruption is costly to fix

SQL Database Design

Normalization

Database normalization reduces redundancy and ensures data integrity.

1st Normal Form (1NF)

Rule: Each column contains atomic (indivisible) values, no repeating groups.

-- ❌ Violates 1NF (multiple values in one column)
CREATE TABLE orders (
  id INT PRIMARY KEY,
  customer_id INT,
  product_ids VARCHAR(255)  -- '101,102,103' (bad!)
);

-- ✅ Follows 1NF
CREATE TABLE orders (
  id INT PRIMARY KEY,
  customer_id INT
);

CREATE TABLE order_items (
  id INT PRIMARY KEY,
  order_id INT,
  product_id INT,
  FOREIGN KEY (order_id) REFERENCES orders(id)
);

2nd Normal Form (2NF)

Rule: Must be in 1NF + all non-key columns depend on the entire primary key.

3rd Normal Form (3NF)

Rule: Must be in 2NF + no transitive dependencies (non-key columns depend only on primary key).


Indexing Strategies

Indexes speed up reads but slow down writes. Use strategically.

When to Create Indexes

-- ✅ Index foreign keys
CREATE INDEX idx_orders_customer_id ON orders(customer_id);

-- ✅ Index frequently queried columns
CREATE INDEX idx_users_email ON users(email);

-- ✅ Index columns used in WHERE, ORDER BY, GROUP BY
CREATE INDEX idx_orders_created_at ON orders(created_at);

-- ✅ Composite index for multi-column queries
CREATE INDEX idx_orders_customer_status ON orders(customer_id, status);

Composite Indexes (Column Order Matters)

-- ✅ Good: Index supports both queries
CREATE INDEX idx_orders_customer_status ON orders(customer_id, status);

-- Query 1: Uses index efficiently
SELECT * FROM orders WHERE customer_id = 123 AND status = 'pending';

-- Query 2: Uses index (customer_id only)
SELECT * FROM orders WHERE customer_id = 123;

-- ❌ Query 3: Doesn't use index (status is second column)
SELECT * FROM orders WHERE status = 'pending';

Rule of Thumb: Put most selective column first, or most frequently queried alone.


Constraints

Use constraints to enforce data integrity at the database level.

CREATE TABLE products (
  id INT PRIMARY KEY,
  price DECIMAL(10, 2) CHECK (price >= 0),
  stock INT CHECK (stock >= 0),
  discount_percent INT CHECK (discount_percent BETWEEN 0 AND 100)
);

Database Migrations

Migration Best Practices

1. Always Reversible

-- Up migration
ALTER TABLE users ADD COLUMN phone VARCHAR(20);

-- Down migration
ALTER TABLE users DROP COLUMN phone;

2. Backward Compatible

-- ✅ Good: Add nullable column
ALTER TABLE users ADD COLUMN middle_name VARCHAR(50);

-- ❌ Bad: Add required column (breaks existing code)
ALTER TABLE users ADD COLUMN middle_name VARCHAR(50) NOT NULL;

3. Data Migrations Separate from Schema Changes

-- Migration 1: Schema change
ALTER TABLE orders ADD COLUMN status VARCHAR(20) DEFAULT 'pending';

-- Migration 2: Data migration
UPDATE orders SET status = 'completed' WHERE completed_at IS NOT NULL;

Quick Start Checklist

When designing a new schema:

  • Identify entities and relationships
  • Choose SQL or NoSQL based on requirements
  • Normalize to 3NF (SQL) or decide embed/reference (NoSQL)
  • Define primary keys (INT auto-increment or UUID)
  • Add foreign key constraints
  • Choose appropriate data types
  • Add unique constraints where needed
  • Plan indexing strategy (foreign keys, WHERE columns)
  • Add NOT NULL constraints for required fields
  • Create CHECK constraints for validation
  • Plan for soft deletes (deleted_at column) if needed
  • Add timestamps (created_at, updated_at)
  • Design migration scripts (up and down)
  • Test migrations on staging

Related Skills

  • alembic-migrations - Alembic-specific migration patterns for SQLAlchemy projects
  • zero-downtime-migration - Safe schema changes without service interruption
  • database-versioning - Version control strategies for database objects
  • caching-strategies - Cache layer design to complement database performance

Key Decisions

DecisionChoiceRationale
Normalization target3NF for OLTPReduces redundancy while maintaining query performance
Primary key strategyINT auto-increment or UUIDUUIDs for distributed systems, INT for single-database
Soft deletesdeleted_at timestamp columnPreserves audit trail, enables recovery, supports compliance
Composite index orderMost selective column firstOptimizes index usage for common query patterns

Skill Version: 2.0.0 Last Updated: 2026-01-08 Maintained by: AI Agent Hub Team

Capability Details

schema-design

Keywords: schema, table, entity, relationship, erd Solves:

  • Design database schema
  • Model relationships
  • ERD creation

normalization

Keywords: normalize, 1nf, 2nf, 3nf, denormalize Solves:

  • Normalization levels
  • When to denormalize
  • Reduce redundancy

indexing

Keywords: index, b-tree, composite, query performance Solves:

  • Which columns to index
  • Optimize slow queries
  • Index types

migrations

Keywords: migration, alter table, zero downtime, backward compatible Solves:

  • Write safe migrations
  • Zero-downtime changes
  • Reversible migrations

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

04

需要参考平台分布和安装热度时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

补充不同宿主或平台的使用分布数据

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Claude Code

26.6%
按下载量换算40

OpenCode

22.38%
按下载量换算34

Antigravity

17.12%
按下载量换算26

Gemini CLI

11.55%
按下载量换算17

windsurf

7.71%
按下载量换算12

trae

3.77%
按下载量换算6

安全审计

暂无安全审计结果可展示。

权限和风险

只读

该 Skill 主要提供规则、说明或参考内容,本身偏只读;真正读写文件、联网或执行命令仍取决于宿主 Agent 的任务。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills