Appearance
DB設計
基本情報
| 項目 | 値 |
|---|---|
| データベース | PostgreSQL 16 |
| ホスティング | Supabase |
| スキーマ名 | public |
テーブル一覧
| No | テーブル名(日本語) | テーブル名(物理) | 説明 |
|---|---|---|---|
| 1 | ユーザー | users | ユーザーアカウント情報 |
| 2 | デッキ | decks | デッキ情報 |
| 3 | デッキカード | deck_cards | デッキ内のカード |
| 4 | カード | cards | MTGカードマスタ |
| 5 | 価格 | prices | カード価格情報 |
| 6 | 価格履歴 | price_history | 価格の履歴データ |
| 7 | お気に入り | favorites | ユーザーのお気に入り |
| 8 | 価格アラート | price_alerts | 価格通知設定 |
| 9 | プレイテストセッション | playtest_sessions | デッキ回しのセッション記録 |
| 10 | プレイテストアクション | playtest_actions | セッション内のアクション履歴 |
ER図
mermaid
erDiagram
users ||--o{ decks : "owns"
users ||--o{ favorites : "has"
users ||--o{ price_alerts : "sets"
users ||--o{ playtest_sessions : "plays"
decks ||--o{ deck_cards : "contains"
decks ||--o{ playtest_sessions : "tested_with"
cards ||--o{ deck_cards : "included_in"
cards ||--o{ prices : "has"
cards ||--o{ price_history : "has"
cards ||--o{ favorites : "bookmarked"
cards ||--o{ price_alerts : "watches"
playtest_sessions ||--o{ playtest_actions : "has"
users {
uuid id PK
text email UK
text display_name
text avatar_url
text role
boolean is_premium
timestamp created_at
timestamp updated_at
}
decks {
uuid id PK
uuid user_id FK
text name
text description
text format
boolean is_public
integer likes_count
integer views_count
timestamp created_at
timestamp updated_at
}
deck_cards {
uuid id PK
uuid deck_id FK
uuid card_id FK
integer quantity
text zone
}
cards {
uuid id PK
text scryfall_id UK
text name
text name_ja
text mana_cost
integer cmc
text type_line
text oracle_text
text colors
text color_identity
text rarity
text set_code
text image_uri
jsonb legalities
timestamp created_at
timestamp updated_at
}
prices {
uuid id PK
uuid card_id FK
text source
text condition
decimal price_jpy
decimal price_usd
boolean in_stock
timestamp fetched_at
}
price_history {
uuid id PK
uuid card_id FK
text source
decimal price_jpy
decimal price_usd
date recorded_date
}
favorites {
uuid id PK
uuid user_id FK
uuid card_id FK
uuid deck_id FK
timestamp created_at
}
price_alerts {
uuid id PK
uuid user_id FK
uuid card_id FK
decimal target_price_jpy
decimal target_price_usd
boolean is_active
timestamp created_at
}
playtest_sessions {
uuid id PK
uuid user_id FK
uuid deck_id FK
integer total_turns
integer final_life
integer mulligan_count
integer duration_seconds
jsonb ai_feedback
timestamp created_at
}
playtest_actions {
uuid id PK
uuid session_id FK
integer turn_number
text action_type
uuid card_id FK
text from_zone
text to_zone
jsonb metadata
timestamp performed_at
}テーブル詳細
users(ユーザー)
| カラム名 | 型 | NULL | キー | 説明 |
|---|---|---|---|---|
| id | uuid | NO | PK | ユーザーID |
| text | NO | UK | メールアドレス | |
| display_name | text | YES | - | 表示名 |
| avatar_url | text | YES | - | アバター画像URL |
| role | text | NO | - | ロール(user/admin) |
| is_premium | boolean | NO | - | プレミアム会員フラグ |
| created_at | timestamp | NO | - | 作成日時 |
| updated_at | timestamp | NO | - | 更新日時 |
decks(デッキ)
| カラム名 | 型 | NULL | キー | 説明 |
|---|---|---|---|---|
| id | uuid | NO | PK | デッキID |
| user_id | uuid | NO | FK | 所有者ユーザーID |
| name | text | NO | - | デッキ名 |
| description | text | YES | - | 説明 |
| format | text | NO | - | フォーマット |
| is_public | boolean | NO | - | 公開フラグ |
| likes_count | integer | NO | - | いいね数 |
| views_count | integer | NO | - | 閲覧数 |
| created_at | timestamp | NO | - | 作成日時 |
| updated_at | timestamp | NO | - | 更新日時 |
deck_cards(デッキカード)
| カラム名 | 型 | NULL | キー | 説明 |
|---|---|---|---|---|
| id | uuid | NO | PK | レコードID |
| deck_id | uuid | NO | FK | デッキID |
| card_id | uuid | NO | FK | カードID |
| quantity | integer | NO | - | 枚数(1-4、土地は無制限) |
| zone | text | NO | - | ゾーン(main/sideboard/commander) |
cards(カード)
| カラム名 | 型 | NULL | キー | 説明 |
|---|---|---|---|---|
| id | uuid | NO | PK | 内部カードID |
| scryfall_id | text | NO | UK | Scryfall ID |
| name | text | NO | - | 英語カード名 |
| name_ja | text | YES | - | 日本語カード名 |
| mana_cost | text | YES | - | マナコスト |
| cmc | integer | NO | - | 点数で見たマナコスト |
| type_line | text | NO | - | タイプ行 |
| oracle_text | text | YES | - | オラクルテキスト |
| colors | text | YES | - | 色(W,U,B,R,G) |
| color_identity | text | YES | - | 色アイデンティティ |
| rarity | text | NO | - | レアリティ |
| set_code | text | NO | - | セットコード |
| image_uri | text | YES | - | 画像URL |
| legalities | jsonb | NO | - | フォーマット別使用可否 |
prices(価格)
| カラム名 | 型 | NULL | キー | 説明 |
|---|---|---|---|---|
| id | uuid | NO | PK | レコードID |
| card_id | uuid | NO | FK | カードID |
| source | text | NO | - | 価格ソース(hareruya/tcgplayer等) |
| condition | text | NO | - | 状態(NM/EX/VG/G) |
| price_jpy | decimal | YES | - | 日本円価格 |
| price_usd | decimal | YES | - | 米ドル価格 |
| in_stock | boolean | NO | - | 在庫有無 |
| fetched_at | timestamp | NO | - | 取得日時 |
playtest_sessions(プレイテストセッション)
| カラム名 | 型 | NULL | キー | 説明 |
|---|---|---|---|---|
| id | uuid | NO | PK | セッションID |
| user_id | uuid | NO | FK | 実行ユーザーID |
| deck_id | uuid | NO | FK | 対象デッキID |
| total_turns | integer | YES | - | 総ターン数 |
| final_life | integer | YES | - | 終了時ライフ |
| mulligan_count | integer | NO | - | マリガン回数 |
| duration_seconds | integer | YES | - | セッション時間(秒) |
| ai_feedback | jsonb | YES | - | AI分析結果JSON |
| created_at | timestamp | NO | - | セッション開始日時 |
playtest_actions(プレイテストアクション)
| カラム名 | 型 | NULL | キー | 説明 |
|---|---|---|---|---|
| id | uuid | NO | PK | アクションID |
| session_id | uuid | NO | FK | セッションID |
| turn_number | integer | NO | - | ターン番号 |
| action_type | text | NO | - | アクション種別(draw/play/tap/discard/exile等) |
| card_id | uuid | YES | FK | 操作対象カードID |
| from_zone | text | YES | - | 移動元ゾーン |
| to_zone | text | YES | - | 移動先ゾーン |
| metadata | jsonb | YES | - | 追加情報(カウンター数、マナ消費等) |
| performed_at | timestamp | NO | - | 実行日時 |
インデックス
| テーブル | インデックス名 | カラム | 種別 |
|---|---|---|---|
| cards | idx_cards_name | name | BTREE |
| cards | idx_cards_scryfall_id | scryfall_id | UNIQUE |
| deck_cards | idx_deck_cards_deck_id | deck_id | BTREE |
| prices | idx_prices_card_id | card_id | BTREE |
| prices | idx_prices_fetched_at | fetched_at | BTREE |
| playtest_sessions | idx_playtest_sessions_user_id | user_id | BTREE |
| playtest_sessions | idx_playtest_sessions_deck_id | deck_id | BTREE |
| playtest_actions | idx_playtest_actions_session_id | session_id | BTREE |