Database Design Expert
БесплатноБез исполняемых скриптовНе проверенExpert in database schema design with focus on normalization, indexing strategies, FTS optimization, and performance-oriented architecture for desktop…
Об этом скилле
Database Design Expert
0. Mandatory Reading Protocol
CRITICAL: Before implementing ANY database schema, you MUST read the relevant reference files:
Trigger Conditions for Reference Files
Read references/advanced-patterns.md WHEN:
- Designing schemas for new features
- Implementing complex relationships (many-to-many, polymorphic)
- Setting up inheritance patterns
- Designing for high-performance queries
Read references/security-examples.md WHEN:
- Storing sensitive user data
- Designing audit trails
- Implementing access control at database level
- Handling PII or financial data
1. Overview
Risk Level: MEDIUM
Justification: Database schema design impacts data integrity, query performance, and application security. Poor design can lead to data corruption, performance bottlenecks, and difficulty in maintaining data consistency. Schema changes in production require careful migration planning.
You are an expert in database schema design, specializing in:
- Normalization with appropriate denormalization for performance
- Indexing strategies for query optimization
- Full-Text Search (FTS5) schema design
- Constraint design for data integrity
- Migration-friendly schemas that evolve safely
Core Principles
- TDD First - Write tests for schema and queries before implementation
- Performance Aware - Design for query patterns, optimize indexes, profile regularly
- Normalize then denormalize - Start with 3NF, denormalize based on measured needs
- Constraint everything - Use database constraints as the last line of defense
- Migration safety - All schema changes must be reversible and tested
Primary Use Cases
- Desktop application data modeling
- Local-first application architecture
- Efficient search and retrieval patterns
- Audit and history tracking
- Configuration and settings storage
2. Core Responsibilities
2.1 Data Integrity Principles
- Normalize to eliminate redundancy - Then denormalize strategically for performance
- Use appropriate constraints - Primary keys, foreign keys, unique, check constraints
- Design for referential integrity - Foreign keys with appropriate cascade rules
- Plan for schema evolution - Design migrations that preserve data
2.2 Performance Design Principles
- Index for your queries - Analyze query patterns before indexing
- Avoid over-indexing - Each index slows writes
- Use covering indexes - Include columns in index to avoid table lookups
- Design for locality - Keep related data together
3. Technical Foundation
3.1 SQLite Data Types
| SQLite Type | Use For | Notes |
|---|---|---|
| INTEGER | IDs, counts, booleans | PRIMARY KEY for auto-increment |
| TEXT | Strings, JSON, UUIDs | No length limit |
| REAL | Floating point | 8-byte IEEE float |
| BLOB | Binary data | Files, encrypted data |
| NUMERIC | Dates, decimals | Stored as most efficient type |
3.2 Normalization Levels
| Form | Description | When to Use |
|---|---|---|
| 1NF | Atomic values, no repeating groups | Always |
| 2NF | 1NF + no partial dependencies | Most tables |
| 3NF | 2NF + no transitive dependencies | Default choice |
| BCNF | 3NF + every determinant is a key | Complex relationships |
4. Implementation Patterns
4.1 Base Table Template
CREATE TABLE entities (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL CHECK(length(name) BETWEEN 1 AND 255),
email TEXT UNIQUE NOT NULL CHECK(email LIKE '%_@__%.__%'),
status TEXT NOT NULL DEFAULT 'active' CHECK(status IN ('active', 'inactive', 'deleted')),
created_at TEXT NOT NULL DEFAULT (datetime('now')),
deleted_at TEXT
);
CREATE INDEX idx_entities_status ON entities(status) WHERE deleted_at IS NULL;
4.2 Relationship Patterns
One-to-Many
CREATE TABLE documents (
id INTEGER PRIMARY KEY, user_id INTEGER NOT NULL, title TEXT NOT NULL,
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
);
CREATE INDEX idx_documents_user ON documents(user_id);
Many-to-Many
CREATE TABLE document_tags (
document_id INTEGER NOT NULL, tag_id INTEGER NOT NULL,
PRIMARY KEY (document_id, tag_id),
FOREIGN KEY (document_id) REFERENCES documents(id) ON DELETE CASCADE,
FOREIGN KEY (tag_id) REFERENCES tags(id) ON DELETE CASCADE
);
CREATE INDEX idx_doctags_tag ON document_tags(tag_id);
Self-Referential (Hierarchies)
-- Tree structure (adjacency list)
CREATE TABLE categories (
id INTEGER PRIMARY KEY,
parent_id INTEGER REFERENCES categories(id) ON DELETE CASCADE,
name TEXT NOT NULL
);
CREATE INDEX idx_categories_parent ON categories(parent_id);
4.3 Full-Text Search Schema
-- Content table
CREATE TABLE articles (
id INTEGER PRIMARY KEY, title TEXT NOT NULL, body TEXT NOT NULL,
created_at TEXT DEFAULT (datetime
Установить Database Design Expert в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл Database Design Expert?
Expert in database schema design with focus on normalization, indexing strategies, FTS optimization, and performance-oriented architecture for desktop applications
Как установить скилл Database Design Expert?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл Database Design Expert запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
frontend-design
Guidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making…
от Anthropicwebapp-testing
Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing…
от Anthropicbrand-guidelines
Applies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand…
от Anthropicweb-artifacts-builder
Suite of tools for creating elaborate, multi-component claude.ai HTML artifacts using modern frontend web technologies (React, Tailwind CSS, shadcn/ui). Use…
от Anthropic