database-schema-designer
БесплатноБез исполняемых скриптовНе проверенUse this skill when designing database schemas for relational (SQL) or document (NoSQL) databases. Provides normalization guidelines, indexing strategies…
от aiskillstore★ 509 звёзд на GitHubОб этом скилле
Database Schema Designer
Overview
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.
When to use this skill:
- 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.
-- ❌ Violates 2NF (customer_name depends only on customer_id, not full key)
CREATE TABLE order_items (
order_id INT,
product_id INT,
customer_id INT,
customer_name VARCHAR(100), -- Depends on customer_id only
quantity INT,
PRIMARY KEY (order_id, product_id)
);
-- ✅ Follows 2NF (customer data in separate table)
CREATE TABLE orders (
id INT PRIMARY KEY,
customer_id INT,
FOREIGN KEY (customer_id) REFERENCES customers(id)
);
CREATE TABLE order_items (
order_id INT,
product_id INT,
quantity INT,
PRIMARY KEY (order_id, product_id)
);
CREATE TABLE customers (
id INT PRIMARY KEY,
name VARCHAR(100)
);
3rd Normal Form (3NF)
Rule: Must be in 2NF + no transitive dependencies (non-key columns depend only on primary key).
-- ❌ Violates 3NF (country depends on postal_code, not on customer_id)
CREATE TABLE customers (
id INT PRIMARY KEY,
name VARCHAR(100),
postal_code VARCHAR(10),
country VARCHAR(50) -- Depends on postal_code, not id
);
-- ✅ Follows 3NF
CREATE TABLE customers (
id INT PRIMARY KEY,
name VARCHAR(100),
postal_code VARCHAR(10),
FOREIGN KEY (postal_code) REFERENCES postal_codes(code)
);
CREATE TABLE postal_codes (
code VARCHAR(10) PRIMARY KEY,
country VARCHAR(50)
);
Denormalization (When to Break Rules)
Sometimes denormalization improves performance for read-heavy applications.
-- Denormalized for performance (caching derived data)
CREATE TABLE orders (
id INT PRIMARY KEY,
customer_id INT,
total_amount DECIMAL(10, 2), -- Calculated from order_items
item_count INT, -- Calculated from order_items
created_at TIMESTAMP
);
-- Trigger or application code keeps denormalized data in sync
When to denormalize:
- Read-heavy applications (reporting, analytics)
- Frequently joined tables causing performance issues
- Pre-calculated aggregates (counts, sums, averages)
- Caching derived data to avoid complex joins
Data Types
Choose appropriate data types for efficiency and accuracy.
String Types
-- Fixed-length (use for predictable lengths)
CHAR(10) -- ISO date: '2025-10-31'
CHAR(2) -- State code: 'CA'
-- Variable-length (use for variable lengths)
VARCHAR(255) -- Email, name, short text
TEXT -- Long text (articles, descriptions)
-- ✅ Good: Appropriate sizes
email VARCHAR(255)
phone_number VARCHAR(20)
postal_code VARCHAR(10)
-- ❌ Bad: Wasteful or too small
email VARCHAR(500) -- Too large
description VARCHAR(50) -- Too small for long text
Numeric Types
-- Integer types
TINYINT -- -128 to 127 (age, status codes)
SMALLINT -- -32,768 to 32,767 (quantities)
INT -- -2.1B to 2.1B (IDs, counts)
BIGINT -- Large numbers (timestamps, large IDs)
-- Decimal types
DECIMAL(10, 2) -- Exact precision (money: $99,999,999.99)
FLOAT -- Approximate (scientific calculations)
DOUBLE
Установить database-schema-designer в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл database-schema-designer?
Use this skill when designing database schemas for relational (SQL) or document (NoSQL) databases. Provides normalization guidelines, indexing strategies, migration patterns, and performance optimization techniques. Ensures scalable, maintainable, and performant data models.
Как установить скилл database-schema-designer?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл database-schema-designer запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
docx
Use this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files) or Word templates (.dotx files). Triggers include…
от AnthropicUse this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple…
от Anthropicxlsx
Use this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing…
от Anthropicpptx
Use this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or…
от Anthropic