designing-databases
データベーススキーマ設計と最適化を支援します。正規化戦略、インデックス設計、パフォーマンス最適化を提供します。データモデル設計、データベース構造の最適化が必要な場合に使用してください。
Best use case
designing-databases is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
データベーススキーマ設計と最適化を支援します。正規化戦略、インデックス設計、パフォーマンス最適化を提供します。データモデル設計、データベース構造の最適化が必要な場合に使用してください。
Teams using designing-databases should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/designing-databases/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How designing-databases Compares
| Feature / Agent | designing-databases | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
データベーススキーマ設計と最適化を支援します。正規化戦略、インデックス設計、パフォーマンス最適化を提供します。データモデル設計、データベース構造の最適化が必要な場合に使用してください。
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# データベース設計と最適化
## 概要
データベースのスキーマ設計、クエリ最適化、パフォーマンスチューニングを包括的に支援するスキルです。
## 実行フロー
### Step 1: 要件分析
#### ビジネス要件の整理
- ユースケースとデータフロー
- トランザクション特性(OLTP vs OLAP)
- データボリューム予測
- 成長予測とスケーラビリティ要件
#### 非機能要件
- **パフォーマンス**: 目標レスポンス時間、スループット
- **可用性**: SLA、ダウンタイム許容度
- **整合性**: ACID要件、結果整合性の許容度
- **セキュリティ**: 暗号化、アクセス制御
### Step 2: データモデリング(新規設計時)
#### 概念モデル(ER図)
エンティティと関係を定義:
```
User (ユーザー)
- user_id (PK)
- email
- name
- created_at
Order (注文)
- order_id (PK)
- user_id (FK)
- total_amount
- status
- created_at
```
#### 論理モデル
- 正規化(第3正規形まで)
- 非正規化のトレードオフ判断
- データ型とサイズの決定
- 制約の定義(NOT NULL、UNIQUE、CHECK)
### Step 3: スキーマ設計
#### テーブル定義
```sql
CREATE TABLE users (
user_id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
email VARCHAR(255) NOT NULL UNIQUE,
name VARCHAR(100) NOT NULL,
password_hash VARCHAR(255) NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE INDEX idx_users_email ON users(email);
```
#### インデックス戦略
**インデックスが効果的な場合:**
- WHERE句で頻繁に検索される列
- JOIN条件で使用される外部キー
- ORDER BY、GROUP BYで使用される列
**複合インデックス:**
```sql
CREATE INDEX idx_orders_user_status
ON orders(user_id, status, created_at);
```
#### パーティショニング
```sql
CREATE TABLE orders (
order_id UUID,
user_id UUID,
total_amount DECIMAL(10, 2),
created_at TIMESTAMP
) PARTITION BY RANGE (created_at);
```
### Step 4: クエリ最適化(既存システム)
#### パフォーマンス分析
```sql
-- 実行計画の確認
EXPLAIN ANALYZE
SELECT u.name, COUNT(o.order_id) as order_count
FROM users u
LEFT JOIN orders o ON u.user_id = o.user_id
GROUP BY u.user_id, u.name;
-- スロークエリTop 10
SELECT query, calls, mean_time, max_time
FROM pg_stat_statements
ORDER BY mean_time DESC
LIMIT 10;
```
#### N+1問題の解消
```javascript
// 改善: Eager Loading
const users = await User.findAll({
include: [{ model: Order }]
});
```
### Step 5: パフォーマンスチューニング
#### データベース設定の最適化
**PostgreSQL:**
```sql
shared_buffers = 4GB
work_mem = 16MB
maintenance_work_mem = 512MB
effective_cache_size = 12GB
```
#### コネクションプール
```javascript
const pool = new Pool({
max: 20,
idleTimeoutMillis: 30000,
connectionTimeoutMillis: 2000,
});
```
### Step 6: スケーラビリティ戦略
- 読み取りレプリカ
- シャーディング
- キャッシング戦略(Redis Cache-aside パターン)
### Step 7: 移行計画(必要に応じて)
**ゼロダウンタイム移行:**
```sql
-- 1. 新カラム追加
ALTER TABLE users ADD COLUMN new_email VARCHAR(255);
-- 2. データ移行
UPDATE users SET new_email = email WHERE new_email IS NULL;
-- 3. 旧カラム削除
ALTER TABLE users DROP COLUMN email;
ALTER TABLE users RENAME COLUMN new_email TO email;
```
## パフォーマンス目標
| 指標 | 目標値 |
| ---------------- | -------------------- |
| クエリレイテンシ | p95 < 100ms |
| API応答時間 | p95 < 200ms |
| キャッシュヒット率| 90%以上 |
| 稼働率 | 99.99% |
## データベース選定ガイド
### SQL Databases
| データベース | 適したユースケース |
| ------------ | ------------------------------ |
| PostgreSQL | 汎用、複雑なクエリ、GIS |
| MySQL | Webアプリ、シンプルなクエリ |
### NoSQL Databases
| データベース | 適したユースケース |
| ------------ | -------------------------- |
| MongoDB | ドキュメント、柔軟なスキーマ |
| Redis | キャッシュ、セッション |
| DynamoDB | サーバーレス、AWS環境 |
## ベストプラクティス
1. **測定に基づく最適化**: 推測ではなくデータに基づいて最適化
2. **将来を見据えた設計**: スケーラビリティを考慮
3. **保守性の確保**: ドキュメント化、命名規則の統一
4. **セキュリティ**: 最小権限の原則、暗号化
5. **バックアップと復旧**: 定期的なバックアップ、DR計画
## 関連ファイル
- [TEMPLATES.md](./TEMPLATES.md) - スキーマテンプレート
- [QUERIES.md](./QUERIES.md) - 便利なクエリ集Related Skills
databases
Work with MongoDB (document database, BSON documents, aggregation pipelines, Atlas cloud) and PostgreSQL (relational database, SQL queries, psql CLI, pgAdmin). Use when designing database schemas, writing queries and aggregations, optimizing indexes for performance, performing database migrations, configuring replication and sharding, implementing backup and restore strategies, managing database users and permissions, analyzing query performance, or administering production databases.
databases-architecture-skill
Master database design (SQL, NoSQL), system architecture, API design (REST, GraphQL), and building scalable systems. Learn PostgreSQL, MongoDB, system design patterns, and enterprise architectures.
bio-clinical-databases-gnomad-frequencies
Query gnomAD for population allele frequencies to assess variant rarity. Use when filtering variants by population frequency for rare disease analysis or determining if a variant is common in the general population.
aposd-designing-deep-modules
Enforce Design-It-Twice workflow: generate 2-3 radically different approaches, compare them, then implement. Use when designing modules, APIs, or classes before implementation. Triggers on: design, create class, add module, implement feature, new service, API design, before implementing. Produces structured design document with approaches, comparison table, choice rationale, and depth check.
acsets-algebraic-databases
ACSets (Attributed C-Sets): Algebraic databases as in-memory data structures. Category-theoretic formalism for relational databases generalizing graphs and data frames.
bgo
Automates the complete Blender build-go workflow, from building and packaging your extension/add-on to removing old versions, installing, enabling, and launching Blender for quick testing and iteration.
django-expert
Expert Django backend development guidance. Use when creating Django models, views, serializers, or APIs; debugging ORM queries or migrations; optimizing database performance; implementing authentication; writing tests; or working with Django REST Framework. Follows Django best practices and modern patterns.
django-developer
Expert Django developer specializing in Async Views, Django Ninja (FastAPI-like), and HTMX patterns for modern full-stack apps.
django-api
Django API development for 2025. Covers Django Ninja (modern, async-first, type-safe) and Django REST Framework (mature, ecosystem-rich). Use when building REST APIs, choosing between frameworks, implementing authentication, permissions, filtering, pagination, or async endpoints.
distributed-tracing
Implement distributed tracing with Jaeger and Tempo to track requests across microservices and identify performance bottlenecks. Use when debugging microservices, analyzing request flows, or implementing observability for distributed systems.
distributed-debugging-debug-trace
You are a debugging expert specializing in setting up comprehensive debugging environments, distributed tracing, and diagnostic tools. Configure debugging workflows, implement tracing solutions, an...
distinctive-frontend-design
Creates distinctive, production-grade frontend interfaces that avoid generic AI aesthetics. Guides bold aesthetic direction, typography, color, motion, and spatial composition for memorable UI. Use when building frontend components, pages, applications, or interfaces, or when the user asks for UI/UX design, styling, or visually striking interfaces.