データモデル概要
Data Model Overview
1. エンティティ概要
Entity Overview
本アプリケーションで管理するデータは AWS 用語(Term) の単一エンティティである。画像ファイルは R2 に格納し、D1 にはキー文字列のみ保持する。
%%{init: {'theme': 'default', 'themeVariables': {'fontSize': '13px'}}}%%
erDiagram
TERM {
int id PK "AUTOINCREMENT"
string name UK "用語名(一意)"
string abbreviation "略称(nullable)"
string category "カテゴリ(nullable)"
string description "説明文"
string descriptionImageKey "R2 オリジナルキー(nullable)"
string descriptionImageSlimKey "R2 軽量版キー(nullable)"
datetime createdAt "DEFAULT NOW"
datetime updatedAt "AUTO UPDATE"
}
PK = Primary Key / UK = Unique Key / nullable フィールドは Prisma では String?
2. Term エンティティ詳細
Term Entity Details
| フィールド名 | 型 | 制約 | 説明 | 例 |
|---|---|---|---|---|
| id | Int | PKAUTO | 主キー | 1 |
| name | String | NOT NULLUNIQUE | 用語名・サービス名 | "Amazon EC2" |
| abbreviation | String? | nullable | 略称・略語 | "EC2" |
| category | String? | nullable | CATEGORIES 定数から選択 |
"Compute" |
| description | String | NOT NULL | 用語の説明文 | "仮想サーバー..." |
| descriptionImageKey | String? | nullable | R2 オリジナル画像キー | terms/original/uuid.png |
| descriptionImageSlimKey | String? | nullable | R2 軽量版キー(Worker が生成後に書き込む) | terms/slim/uuid.webp |
| createdAt | DateTime | NOT NULLDEFAULT NOW | 登録日時 | 2024-01-15T10:00:00Z |
| updatedAt | DateTime | NOT NULLAUTO UPDATE | 最終更新日時 | 2024-01-20T15:30:00Z |
3. Prisma スキーマ概要
Prisma Schema Overview
model Term {
id Int @id @default(autoincrement())
name String @unique
abbreviation String?
category String?
description String
descriptionImageKey String?
descriptionImageSlimKey String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
4. カテゴリ一覧(固定値)
Category List (Fixed Values)
カテゴリは src/features/terms/constants/categories.ts に定数として定義する。UI では Select / チップから選択のみ可能とし、自由入力は受け付けない。API バリデーション(Zod)でも同定数を使って許可値を制限する。
"Compute"
コンピューティング
EC2, Lambda, ECS, EKS
"Storage"
ストレージ
S3, EBS, EFS, Glacier
"Database"
データベース
RDS, DynamoDB, ElastiCache, Aurora
"Networking"
ネットワーク
VPC, Route 53, CloudFront, ELB
"Security"
セキュリティ
IAM, KMS, WAF, Shield
"Monitoring"
モニタリング
CloudWatch, CloudTrail, Config
"Developer"
開発者ツール
CodeCommit, CodeBuild, CodeDeploy
"Integration"
統合・メッセージ
SQS, SNS, EventBridge, Step Functions
"AI/ML"
AI・機械学習
SageMaker, Bedrock, Rekognition
"Management"
管理・ガバナンス
Organizations, Control Tower, SSM
"Other"
上記以外
—
カテゴリを追加・変更する場合は src/features/terms/constants/categories.ts を編集する。DB スキーマ(TEXT 型)の変更は不要。
5. データ量の想定
Estimated Data Volume
50〜100
初期投入
データ数
データ数
〜500
最大データ数
(想定)
(想定)
20
1ページあたりの
表示件数
表示件数
25
最大ページ数
(500件時)
(500件時)
Cloudflare D1 は SQLite 互換のため、数千件のデータまで十分なパフォーマンスを発揮する。D1 の無料枠(500万行/日の読み取り)もこの規模では大きく上回らない。
6. 検索クエリのデータアクセスパターン
Search Query Data Access Patterns
| 操作 | 種別 | Prisma クエリ | 備考 |
|---|---|---|---|
| 全件取得(ページング) | READ | findMany({ skip, take, orderBy }) |
page, limit でページング |
| 単語名検索 | READ | findMany({ where: { name: { contains: q } } }) |
SQLite LIKE で ASCII 大小無視 |
| 説明文検索 | READ | findMany({ where: { description: { contains: q } } }) |
同上 |
| カテゴリ絞込 | READ | findMany({ where: { category } }) |
category パラメータ指定時 |
| 件数取得 | READ | count({ where: ... }) |
ページング計算用 |
| 1 件取得 | READ | findUnique({ where: { id } }) |
編集ダイアログ表示時 |
| 用語作成 | WRITE | create({ data: { name, abbreviation, category, description, ... } }) |
— |
| 用語更新 | WRITE | update({ where: { id }, data: { ... } }) |
— |
| 用語削除 | DELETE | delete({ where: { id } }) |
— |
Cloudflare D1 は SQLite 互換のためmode: "insensitive"は使用できない。containsのみで対応し、大文字・小文字の区別なし検索は SQLite のLIKEデフォルト動作(ASCII 文字のみ大小無視)を活用する。