schema-designer
БесплатноБез исполняемых скриптовНе проверенDesign database schemas with proper normalization, relationships, constraints, and indexes. Use when creating database tables, modeling data relationships, or…
от armanzeroeight★ 30 звёзд на GitHubОб этом скилле
Schema Designer
Design relational database schemas with proper structure, relationships, and constraints.
Quick Start
Identify entities, define relationships, normalize to 3NF, add constraints and indexes.
Instructions
Schema Design Process
- Identify entities (tables)
- Define attributes (columns)
- Establish relationships (foreign keys)
- Apply normalization
- Add constraints
- Create indexes
Entity Identification
Main entities:
- Core business objects
- Things that need to be stored
- Independent concepts
Example - E-commerce:
- Users
- Products
- Orders
- Categories
- Reviews
Table Definition
Basic table structure:
CREATE TABLE users (
id SERIAL PRIMARY KEY,
email VARCHAR(255) UNIQUE NOT NULL,
name VARCHAR(100) NOT NULL,
password_hash VARCHAR(255) NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
Data types (PostgreSQL):
SERIAL: Auto-incrementing integerINTEGER: Whole numbersBIGINT: Large integersVARCHAR(n): Variable-length stringTEXT: Unlimited textBOOLEAN: True/falseTIMESTAMP: Date and timeDATE: Date onlyJSON/JSONB: JSON dataDECIMAL(p,s): Precise decimals
Relationships
One-to-Many:
CREATE TABLE posts (
id SERIAL PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users(id),
title VARCHAR(200) NOT NULL,
content TEXT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
Many-to-Many (junction table):
CREATE TABLE products (
id SERIAL PRIMARY KEY,
name VARCHAR(200) NOT NULL
);
CREATE TABLE tags (
id SERIAL PRIMARY KEY,
name VARCHAR(50) UNIQUE NOT NULL
);
CREATE TABLE product_tags (
product_id INTEGER REFERENCES products(id) ON DELETE CASCADE,
tag_id INTEGER REFERENCES tags(id) ON DELETE CASCADE,
PRIMARY KEY (product_id, tag_id)
);
One-to-One:
CREATE TABLE user_profiles (
user_id INTEGER PRIMARY KEY REFERENCES users(id) ON DELETE CASCADE,
bio TEXT,
avatar_url VARCHAR(500),
phone VARCHAR(20)
);
Normalization
First Normal Form (1NF):
- Atomic values (no arrays in cells)
- Each column has unique name
- Order doesn't matter
-- Bad: Multiple values in one column
CREATE TABLE users (
id INTEGER,
phones VARCHAR(200) -- "555-1234, 555-5678"
);
-- Good: Separate table
CREATE TABLE user_phones (
user_id INTEGER REFERENCES users(id),
phone VARCHAR(20)
);
Second Normal Form (2NF):
- Must be in 1NF
- No partial dependencies
-- Bad: Order details depend on part of composite key
CREATE TABLE order_items (
order_id INTEGER,
product_id INTEGER,
product_name VARCHAR(200), -- Depends only on product_id
quantity INTEGER,
PRIMARY KEY (order_id, product_id)
);
-- Good: Product name in products table
CREATE TABLE order_items (
order_id INTEGER,
product_id INTEGER REFERENCES products(id),
quantity INTEGER,
PRIMARY KEY (order_id, product_id)
);
Third Normal Form (3NF):
- Must be in 2NF
- No transitive dependencies
-- Bad: City depends on zip_code
CREATE TABLE addresses (
id INTEGER PRIMARY KEY,
street VARCHAR(200),
zip_code VARCHAR(10),
city VARCHAR(100) -- Depends on zip_code
);
-- Good: Separate zip_codes table
CREATE TABLE zip_codes (
code VARCHAR(10) PRIMARY KEY,
city VARCHAR(100),
state VARCHAR(2)
);
CREATE TABLE addresses (
id INTEGER PRIMARY KEY,
street VARCHAR(200),
zip_code VARCHAR(10) REFERENCES zip_codes(code)
);
Constraints
Primary Key:
id SERIAL PRIMARY KEY
-- Or composite
PRIMARY KEY (user_id, post_id)
Foreign Key:
user_id INTEGER REFERENCES users(id)
-- With cascade
user_id INTEGER REFERENCES users(id) ON DELETE CASCADE
-- With restrict
user_id INTEGER REFERENCES users(id) ON DELETE RESTRICT
Unique:
email VARCHAR(255) UNIQUE NOT NULL
-- Or composite unique
UNIQUE (user_id, product_id)
Not Null:
name VARCHAR(100) NOT NULL
Check:
age INTEGER CHECK (age >= 0 AND age <= 150)
price DECIMAL(10,2) CHECK (price > 0)
status VARCHAR(20) CHECK (status IN ('pending', 'active', 'cancelled'))
Default:
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
status VARCHAR(20) DEFAULT 'pending'
is_active BOOLEAN DEFAULT true
Indexes
Single column:
CREATE INDEX idx_users_email ON users(email);
CREATE INDEX idx_posts_created_at ON posts(created_at);
Composite index:
CREATE INDEX idx_posts_user_created ON posts(user_id, created_at);
Unique index:
CREATE UNIQUE INDEX idx_users_email_unique ON users(email);
Partial index:
CREATE INDEX idx_active_users ON users(email) WHERE is_active = true;
When to index:
- Foreign keys
- Columns in WHERE clauses
- Columns in JOIN conditions
- Columns in ORDER
Установить schema-designer в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл schema-designer?
Design database schemas with proper normalization, relationships, constraints, and indexes. Use when creating database tables, modeling data relationships, or designing database structure.
Как установить скилл schema-designer?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл schema-designer запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic