---
name: data-model-designer
description: |-
  概念データモデル（CDM）、論理データモデル（LDM）、物理データモデル（PDM）を段階的に設計・出力するSkill。
  「データモデルを作って」「ER図を書いて」「テーブル設計して」「DDLを生成して」「エンティティを整理して」「データ辞書を作って」
  「概念モデル」「論理モデル」「物理モデル」などの依頼で発動する。
  出力はMermaid ER図、Markdown（用語集・データ辞書・設計書）、SQL DDL。
title: data-model-designer
canonical_url: https://skilld.dev/gh/superstone-han/dotfiles/data-model-designer
last_updated: 2026-10-06T22:02:34.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> Supporting files, fetch one when the Skill refers to it: [reference.md](https://skilld.dev/api/skills-raw/superstone-han/dotfiles/data-model-designer/reference.md), [templates/conceptual.md](https://skilld.dev/api/skills-raw/superstone-han/dotfiles/data-model-designer/templates/conceptual.md), [templates/logical.md](https://skilld.dev/api/skills-raw/superstone-han/dotfiles/data-model-designer/templates/logical.md), [templates/physical.md](https://skilld.dev/api/skills-raw/superstone-han/dotfiles/data-model-designer/templates/physical.md).
>
> If the user asked to install this Skill, run `npx skilld install superstone-han/dotfiles/data-model-designer`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/data-model-designer`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/superstone-han/dotfiles/data-model-designer) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/data-model-designer`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/data-model-designer --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/data-model-designer --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# Data Model Designer

概念→論理→物理の3段階でデータモデルを設計し、ER図・データ辞書・DDLを出力するSkill。

## Goals
- ユーザーの業務要件から **概念/論理/物理データモデル** を段階的に設計する
- **Mermaid ER図**（概念ERD・論理ERD・物理ERD）を生成する
- **データ辞書**（属性定義・制約・型）を整理する
- **DDL**（CREATE TABLE等）を生成する
- 各段階で **チェックリストによる品質担保** を行う

## Non-goals
- 実際のDB構築・マイグレーション実行
- 性能チューニングの実測・ベンチマーク
- 特定ツール（ERwin、A5:SQL等）のファイル出力

---

## Inputs（入力の期待形式）

以下のいずれか、または組み合わせ：

1. **業務要件の説明**（自然言語）
   - 例：「ECサイトの注文管理。顧客が商品を注文し、配送先を指定する」
2. **エンティティ候補のリスト**
   - 例：「顧客、注文、商品、配送先」
3. **既存テーブル定義/DDL**（リバース用）
4. **作成する段階の指定**（任意）
   - 「概念だけ」「論理まで」「物理まで全部」
5. **DBMS指定**（物理の場合）
   - 例：「PostgreSQL」「MySQL 8」「SQLite」

---

## Outputs（成果物）

### 概念データモデル（CDM）
- 概念ER図（Mermaid erDiagram）
- 用語集（エンティティ定義）
- スコープ/前提メモ

### 論理データモデル（LDM）
- 論理ER図（属性・PK/FK・カーディナリティ付き）
- データ辞書（属性定義・型・制約・必須/任意）
- 業務ルール一覧

### 物理データモデル（PDM）
- 物理ER図（テーブル・カラム・型・索引）
- DDL一式（CREATE TABLE/INDEX/制約）
- インデックス設計根拠
- 運用設計メモ（監査カラム、論理削除等）

---

## Instructions（設計手順）

### Phase 1: 概念データモデル

1. **エンティティ抽出**
   - 業務要件から主要な「もの」「概念」を洗い出す
   - 名詞に注目（顧客、注文、商品…）

2. **関係の整理**
   - エンティティ間の関係を「〜する」「〜を持つ」で記述
   - 多重度は大まかに（1対多、多対多）

3. **用語の統一**
   - 同義語を潰す（ユーザー=会員=アカウント？）
   - 用語集として定義を明文化

4. **概念ERD出力**
   - Mermaid erDiagramで出力
   - 属性は書かない（エンティティと関係のみ）

5. **検証**
   - 代表ユースケースでエンティティが足りているか確認

### Phase 2: 論理データモデル

1. **属性の定義**
   - 各エンティティに属性を追加
   - 属性ごとに「意味」「例」を明記

2. **キーの決定**
   - 主キー（PK）：自然キー or サロゲートキー
   - 外部キー（FK）：関係をキーで表現

3. **カーディナリティ詳細化**
   - 1:1, 1:N, N:M を明確に
   - N:Mは中間エンティティで解決

4. **正規化**
   - 第3正規形を目指す
   - 冗長・更新異常を排除

5. **論理ERD・データ辞書出力**

### Phase 3: 物理データモデル

1. **DBMS決定**
   - 対象DBMSを確認（PostgreSQL/MySQL/SQLite等）

2. **型マッピング**
   - 論理型→物理型へ変換
   - 桁数、NULL、デフォルト決定

3. **テーブル/カラム命名**
   - snake_case統一
   - 予約語回避

4. **インデックス設計**
   - 想定クエリから逆算
   - WHERE/JOIN/ORDER BY条件を考慮

5. **運用カラム追加**
   - created_at, updated_at
   - 論理削除（deleted_at）必要なら

6. **DDL生成**
   - CREATE TABLE/INDEX/制約

---

## Quality Checklist

### 概念モデル
- [ ] 業務用語で書かれている（DB用語なし）
- [ ] エンティティの境界・スコープが明確
- [ ] 同義語/多義語が整理されている
- [ ] 代表ユースケースで検証済み

### 論理モデル
- [ ] 全属性に定義（意味）がある
- [ ] PK/FKが明確
- [ ] カーディナリティが正確
- [ ] N:Mは中間エンティティで解決
- [ ] 正規化されている（理由なき冗長なし）

### 物理モデル
- [ ] DBMS前提が明記
- [ ] データ型・NULL・デフォルトが具体的
- [ ] インデックスに根拠がある
- [ ] 運用カラム（監査/論理削除等）考慮済み
- [ ] DDLが実行可能

---

## Examples

### 発動する例
- 「ECサイトのデータモデルを作って」
- 「顧客・注文・商品のER図を書いて」
- 「このシステムのテーブル設計をして」
- 「論理データモデルを作成して」
- 「PostgreSQLでDDLを生成して」
- 「データ辞書を整理して」
- 「概念ERDをMermaidで」

### 発動しない例
- 「SQLクエリを書いて」（クエリ作成は別タスク）
- 「DBのパフォーマンスを改善して」（チューニングは別タスク）
- 「マイグレーションを実行して」（実行は別タスク）

---

## References

詳細な設計指針は `reference.md` を参照。
テンプレートは `templates/` ディレクトリを参照。
