# ER図

本ドキュメントでは、Medusaコマースプラットフォームのエンティティ関連図（ER図）をMermaid形式で記述します。

## 全体概要

Medusaのデータモデルは、以下の主要なドメインに分類されます：

1. **商品管理（Product）**: 商品、バリアント、カテゴリ、オプションなど
2. **注文管理（Order）**: 注文、明細、返品、交換など
3. **カート管理（Cart）**: カート、明細
4. **顧客管理（Customer）**: 顧客、顧客グループ、住所
5. **決済管理（Payment）**: 決済コレクション、決済、返金
6. **在庫管理（Inventory）**: 在庫アイテム、在庫レベル、予約
7. **フルフィルメント（Fulfillment）**: フルフィルメント、配送オプション
8. **プロモーション（Promotion）**: プロモーション、キャンペーン
9. **マスターデータ**: リージョン、通貨、販売チャネル

---

## 1. 商品管理モジュール ER図

```mermaid
erDiagram
    Product ||--o{ ProductVariant : has
    Product ||--o{ ProductOption : has
    Product ||--o{ ProductImage : has
    Product }o--|| ProductType : belongs_to
    Product }o--|| ProductCollection : belongs_to
    Product }o--o{ ProductTag : has
    Product }o--o{ ProductCategory : belongs_to

    ProductVariant }o--o{ ProductOptionValue : has
    ProductVariant }o--o{ ProductImage : has

    ProductOption ||--o{ ProductOptionValue : has

    ProductCategory ||--o{ ProductCategory : has_children

    Product {
        varchar id PK "prod_xxx"
        text title
        text handle UK
        text subtitle
        text description
        boolean is_giftcard
        enum status
        text thumbnail
        text weight
        text length
        text height
        text width
        text origin_country
        text hs_code
        text mid_code
        text material
        boolean discountable
        text external_id
        varchar type_id FK
        varchar collection_id FK
        jsonb metadata
        timestamp created_at
        timestamp updated_at
        timestamp deleted_at
    }

    ProductVariant {
        varchar id PK "variant_xxx"
        text title
        text sku UK
        text barcode UK
        text ean UK
        text upc UK
        boolean allow_backorder
        boolean manage_inventory
        text hs_code
        text origin_country
        text mid_code
        text material
        numeric weight
        numeric length
        numeric height
        numeric width
        integer variant_rank
        text thumbnail
        varchar product_id FK
        jsonb metadata
        timestamp created_at
        timestamp updated_at
        timestamp deleted_at
    }

    ProductCategory {
        varchar id PK "pcat_xxx"
        text name
        text description
        text handle UK
        text mpath
        boolean is_active
        boolean is_internal
        integer rank
        varchar parent_category_id FK
        jsonb metadata
        timestamp created_at
        timestamp updated_at
        timestamp deleted_at
    }

    ProductOption {
        varchar id PK "opt_xxx"
        text title
        varchar product_id FK
        jsonb metadata
        timestamp created_at
        timestamp updated_at
        timestamp deleted_at
    }

    ProductOptionValue {
        varchar id PK "optval_xxx"
        text value
        varchar option_id FK
        jsonb metadata
        timestamp created_at
        timestamp updated_at
        timestamp deleted_at
    }

    ProductImage {
        varchar id PK "img_xxx"
        text url
        integer rank
        varchar product_id FK
        jsonb metadata
        timestamp created_at
        timestamp updated_at
        timestamp deleted_at
    }

    ProductTag {
        varchar id PK "ptag_xxx"
        text value UK
        jsonb metadata
        timestamp created_at
        timestamp updated_at
        timestamp deleted_at
    }

    ProductType {
        varchar id PK "ptyp_xxx"
        text value UK
        jsonb metadata
        timestamp created_at
        timestamp updated_at
        timestamp deleted_at
    }

    ProductCollection {
        varchar id PK "pcol_xxx"
        text title
        text handle UK
        jsonb metadata
        timestamp created_at
        timestamp updated_at
        timestamp deleted_at
    }
```

---

## 2. 注文管理モジュール ER図

```mermaid
erDiagram
    Order ||--o{ OrderItem : has
    Order ||--o{ OrderShipping : has
    Order ||--o{ OrderTransaction : has
    Order ||--o{ OrderSummary : has
    Order ||--o{ OrderCreditLine : has
    Order ||--o{ Return : has
    Order }o--|| OrderAddress : shipping_address
    Order }o--|| OrderAddress : billing_address

    Return ||--o{ ReturnItem : has
    Return ||--o{ OrderShipping : has
    Return ||--o{ OrderTransaction : has
    Return }o--o| OrderExchange : belongs_to
    Return }o--o| OrderClaim : belongs_to

    OrderClaim ||--o{ OrderClaimItem : has
    OrderClaim ||--o{ OrderShipping : has
    OrderClaim ||--o{ OrderTransaction : has
    OrderClaim }o--|| Order : belongs_to

    OrderExchange ||--o{ OrderExchangeItem : has
    OrderExchange ||--o{ OrderShipping : has
    OrderExchange ||--o{ OrderTransaction : has
    OrderExchange }o--|| Order : belongs_to

    OrderItem ||--o{ OrderLineItem : has
    OrderLineItem ||--o{ OrderLineItemTaxLine : has
    OrderLineItem ||--o{ OrderLineItemAdjustment : has

    OrderShipping ||--o{ OrderShippingMethod : has
    OrderShippingMethod ||--o{ OrderShippingMethodTaxLine : has
    OrderShippingMethod ||--o{ OrderShippingMethodAdjustment : has

    Order {
        varchar id PK "order_xxx"
        serial display_id
        text custom_display_id UK
        varchar region_id
        varchar customer_id
        integer version
        varchar sales_channel_id
        enum status
        boolean is_draft_order
        text email
        text currency_code
        text locale
        boolean no_notification
        varchar shipping_address_id FK
        varchar billing_address_id FK
        timestamp canceled_at
        jsonb metadata
        timestamp created_at
        timestamp updated_at
        timestamp deleted_at
    }

    OrderAddress {
        varchar id PK "ordaddr_xxx"
        varchar customer_id
        text company
        text first_name
        text last_name
        text address_1
        text address_2
        text city
        text country_code
        text province
        text postal_code
        text phone
        jsonb metadata
        timestamp created_at
        timestamp updated_at
        timestamp deleted_at
    }

    OrderLineItem {
        varchar id PK "ordli_xxx"
        text title
        text subtitle
        text thumbnail
        varchar variant_id
        varchar product_id
        text product_title
        text product_description
        text variant_sku
        text variant_title
        jsonb variant_option_values
        boolean requires_shipping
        boolean is_giftcard
        boolean is_discountable
        boolean is_tax_inclusive
        numeric compare_at_unit_price
        numeric unit_price
        boolean is_custom_price
        jsonb metadata
        timestamp created_at
        timestamp updated_at
        timestamp deleted_at
    }

    OrderTransaction {
        varchar id PK "ordtrx_xxx"
        integer version
        numeric amount
        text currency_code
        text reference
        varchar reference_id
        varchar order_id FK
        varchar return_id FK
        varchar exchange_id FK
        varchar claim_id FK
        timestamp created_at
        timestamp updated_at
        timestamp deleted_at
    }

    Return {
        varchar id PK "return_xxx"
        integer order_version
        serial display_id
        enum status
        varchar location_id
        boolean no_notification
        numeric refund_amount
        varchar created_by
        varchar order_id FK
        varchar exchange_id FK
        varchar claim_id FK
        timestamp requested_at
        timestamp received_at
        timestamp canceled_at
        jsonb metadata
        timestamp created_at
        timestamp updated_at
        timestamp deleted_at
    }

    OrderClaim {
        varchar id PK "claim_xxx"
        integer order_version
        serial display_id
        enum type
        boolean no_notification
        numeric refund_amount
        varchar created_by
        varchar order_id FK
        varchar return_id FK
        timestamp canceled_at
        jsonb metadata
        timestamp created_at
        timestamp updated_at
        timestamp deleted_at
    }

    OrderExchange {
        varchar id PK "oexc_xxx"
        integer order_version
        serial display_id
        boolean no_notification
        numeric difference_due
        boolean allow_backorder
        varchar created_by
        varchar order_id FK
        varchar return_id FK
        timestamp canceled_at
        jsonb metadata
        timestamp created_at
        timestamp updated_at
        timestamp deleted_at
    }

    OrderItem {
        varchar id PK
        varchar order_id FK
        varchar line_item_id FK
        integer quantity
        timestamp created_at
        timestamp updated_at
        timestamp deleted_at
    }

    OrderShipping {
        varchar id PK
        varchar order_id FK
        varchar return_id FK
        varchar exchange_id FK
        varchar claim_id FK
        varchar shipping_method_id FK
        timestamp created_at
        timestamp updated_at
        timestamp deleted_at
    }

    OrderSummary {
        varchar id PK
        varchar order_id FK
        integer version
        jsonb totals
        timestamp created_at
        timestamp updated_at
        timestamp deleted_at
    }
```

---

## 3. カート管理モジュール ER図

```mermaid
erDiagram
    Cart ||--o{ CartLineItem : has
    Cart ||--o{ CartShippingMethod : has
    Cart ||--o{ CartCreditLine : has
    Cart }o--|| CartAddress : shipping_address
    Cart }o--|| CartAddress : billing_address

    CartLineItem ||--o{ CartLineItemTaxLine : has
    CartLineItem ||--o{ CartLineItemAdjustment : has

    CartShippingMethod ||--o{ CartShippingMethodTaxLine : has
    CartShippingMethod ||--o{ CartShippingMethodAdjustment : has

    Cart {
        varchar id PK "cart_xxx"
        varchar region_id
        varchar customer_id
        varchar sales_channel_id
        text email
        text currency_code
        text locale
        varchar shipping_address_id FK
        varchar billing_address_id FK
        timestamp completed_at
        jsonb metadata
        timestamp created_at
        timestamp updated_at
        timestamp deleted_at
    }

    CartAddress {
        varchar id PK
        varchar customer_id
        text company
        text first_name
        text last_name
        text address_1
        text address_2
        text city
        text country_code
        text province
        text postal_code
        text phone
        jsonb metadata
        timestamp created_at
        timestamp updated_at
        timestamp deleted_at
    }

    CartLineItem {
        varchar id PK "cali_xxx"
        text title
        text subtitle
        text thumbnail
        integer quantity
        varchar variant_id
        varchar product_id
        text product_title
        text variant_sku
        text variant_title
        jsonb variant_option_values
        boolean requires_shipping
        boolean is_discountable
        boolean is_giftcard
        boolean is_tax_inclusive
        boolean is_custom_price
        numeric compare_at_unit_price
        numeric unit_price
        varchar cart_id FK
        jsonb metadata
        timestamp created_at
        timestamp updated_at
        timestamp deleted_at
    }

    CartShippingMethod {
        varchar id PK
        text name
        jsonb description
        numeric amount
        boolean is_tax_inclusive
        boolean is_custom_amount
        varchar shipping_option_id
        varchar cart_id FK
        jsonb data
        jsonb metadata
        timestamp created_at
        timestamp updated_at
        timestamp deleted_at
    }

    CartCreditLine {
        varchar id PK
        varchar cart_id FK
        numeric amount
        text reference
        varchar reference_id
        jsonb metadata
        timestamp created_at
        timestamp updated_at
        timestamp deleted_at
    }

    CartLineItemTaxLine {
        varchar id PK
        varchar item_id FK
        text code
        numeric rate
        text provider_id
        jsonb metadata
        timestamp created_at
        timestamp updated_at
        timestamp deleted_at
    }

    CartLineItemAdjustment {
        varchar id PK
        varchar item_id FK
        text code
        numeric amount
        varchar promotion_id
        text provider_id
        jsonb metadata
        timestamp created_at
        timestamp updated_at
        timestamp deleted_at
    }
```

---

## 4. 顧客管理モジュール ER図

```mermaid
erDiagram
    Customer ||--o{ CustomerAddress : has
    Customer }o--o{ CustomerGroup : belongs_to

    Customer {
        varchar id PK "cus_xxx"
        text company_name
        text first_name
        text last_name
        text email UK
        text phone
        boolean has_account
        varchar created_by
        jsonb metadata
        timestamp created_at
        timestamp updated_at
        timestamp deleted_at
    }

    CustomerGroup {
        varchar id PK "cusgroup_xxx"
        text name UK
        varchar created_by
        jsonb metadata
        timestamp created_at
        timestamp updated_at
        timestamp deleted_at
    }

    CustomerAddress {
        varchar id PK "cuaddr_xxx"
        text address_name
        boolean is_default_shipping
        boolean is_default_billing
        text company
        text first_name
        text last_name
        text address_1
        text address_2
        text city
        text country_code
        text province
        text postal_code
        text phone
        varchar customer_id FK
        jsonb metadata
        timestamp created_at
        timestamp updated_at
        timestamp deleted_at
    }

    CustomerGroupCustomer {
        varchar customer_id FK
        varchar customer_group_id FK
        timestamp created_at
        timestamp updated_at
    }
```

---

## 5. 決済管理モジュール ER図

```mermaid
erDiagram
    PaymentCollection ||--o{ PaymentSession : has
    PaymentCollection ||--o{ Payment : has
    PaymentCollection }o--o{ PaymentProvider : uses

    Payment ||--o{ Refund : has
    Payment ||--o{ Capture : has
    Payment }o--|| PaymentSession : belongs_to

    Refund }o--o| RefundReason : has

    PaymentCollection {
        varchar id PK "pay_col_xxx"
        text currency_code
        numeric amount
        numeric authorized_amount
        numeric captured_amount
        numeric refunded_amount
        enum status
        timestamp completed_at
        jsonb metadata
        timestamp created_at
        timestamp updated_at
        timestamp deleted_at
    }

    PaymentSession {
        varchar id PK "payses_xxx"
        text currency_code
        numeric amount
        varchar provider_id
        jsonb data
        jsonb context
        enum status
        timestamp authorized_at
        varchar payment_collection_id FK
        jsonb metadata
        timestamp created_at
        timestamp updated_at
        timestamp deleted_at
    }

    Payment {
        varchar id PK "pay_xxx"
        numeric amount
        text currency_code
        varchar provider_id
        varchar payment_collection_id FK
        varchar payment_session_id FK
        jsonb data
        timestamp captured_at
        timestamp canceled_at
        jsonb metadata
        timestamp created_at
        timestamp updated_at
        timestamp deleted_at
    }

    Refund {
        varchar id PK "ref_xxx"
        numeric amount
        varchar payment_id FK
        varchar refund_reason_id FK
        text note
        varchar created_by
        jsonb metadata
        timestamp created_at
        timestamp updated_at
        timestamp deleted_at
    }

    Capture {
        varchar id PK "capt_xxx"
        numeric amount
        varchar payment_id FK
        varchar created_by
        jsonb metadata
        timestamp created_at
        timestamp updated_at
        timestamp deleted_at
    }

    PaymentProvider {
        varchar id PK
        boolean is_enabled
        timestamp created_at
        timestamp updated_at
        timestamp deleted_at
    }

    RefundReason {
        varchar id PK
        text label
        text description
        jsonb metadata
        timestamp created_at
        timestamp updated_at
        timestamp deleted_at
    }
```

---

## 6. 在庫管理モジュール ER図

```mermaid
erDiagram
    InventoryItem ||--o{ InventoryLevel : has
    InventoryItem ||--o{ ReservationItem : has

    InventoryItem {
        varchar id PK "iitem_xxx"
        text sku UK
        text origin_country
        text hs_code
        text mid_code
        text material
        numeric weight
        numeric length
        numeric height
        numeric width
        boolean requires_shipping
        text description
        text title
        text thumbnail
        jsonb metadata
        timestamp created_at
        timestamp updated_at
        timestamp deleted_at
    }

    InventoryLevel {
        varchar id PK "ilev_xxx"
        varchar location_id
        varchar inventory_item_id FK
        numeric stocked_quantity
        numeric reserved_quantity
        numeric incoming_quantity
        jsonb metadata
        timestamp created_at
        timestamp updated_at
        timestamp deleted_at
    }

    ReservationItem {
        varchar id PK "resitem_xxx"
        varchar line_item_id
        boolean allow_backorder
        varchar location_id
        numeric quantity
        jsonb raw_quantity
        text external_id
        text description
        varchar created_by
        varchar inventory_item_id FK
        jsonb metadata
        timestamp created_at
        timestamp updated_at
        timestamp deleted_at
    }

    StockLocation {
        varchar id PK "sloc_xxx"
        text name
        varchar address_id FK
        jsonb metadata
        timestamp created_at
        timestamp updated_at
        timestamp deleted_at
    }

    StockLocationAddress {
        varchar id PK
        text company
        text first_name
        text last_name
        text address_1
        text address_2
        text city
        text country_code
        text province
        text postal_code
        text phone
        jsonb metadata
        timestamp created_at
        timestamp updated_at
        timestamp deleted_at
    }

    StockLocation }o--|| StockLocationAddress : has
```

---

## 7. プロモーション管理モジュール ER図

```mermaid
erDiagram
    Campaign ||--o{ Promotion : has
    Campaign ||--o| CampaignBudget : has

    Promotion ||--o| ApplicationMethod : has
    Promotion }o--o{ PromotionRule : has

    PromotionRule ||--o{ PromotionRuleValue : has

    Campaign {
        varchar id PK "procamp_xxx"
        text name
        text description
        text campaign_identifier UK
        timestamp starts_at
        timestamp ends_at
        timestamp created_at
        timestamp updated_at
        timestamp deleted_at
    }

    CampaignBudget {
        varchar id PK
        enum type
        numeric limit
        numeric used
        varchar campaign_id FK
        timestamp created_at
        timestamp updated_at
        timestamp deleted_at
    }

    Promotion {
        varchar id PK "promo_xxx"
        text code UK
        boolean is_automatic
        boolean is_tax_inclusive
        integer limit
        integer used
        enum type
        enum status
        varchar campaign_id FK
        jsonb metadata
        timestamp created_at
        timestamp updated_at
        timestamp deleted_at
    }

    ApplicationMethod {
        varchar id PK
        enum type
        enum target_type
        enum allocation
        numeric value
        numeric max_quantity
        numeric buy_rules_min_quantity
        numeric apply_to_quantity
        varchar promotion_id FK
        text currency_code
        jsonb metadata
        timestamp created_at
        timestamp updated_at
        timestamp deleted_at
    }

    PromotionRule {
        varchar id PK
        text attribute
        text operator
        text description
        jsonb values
        timestamp created_at
        timestamp updated_at
        timestamp deleted_at
    }

    PromotionRuleValue {
        varchar id PK
        text value
        varchar promotion_rule_id FK
        timestamp created_at
        timestamp updated_at
        timestamp deleted_at
    }
```

---

## 8. フルフィルメント管理モジュール ER図

```mermaid
erDiagram
    FulfillmentSet ||--o{ ServiceZone : has
    ServiceZone ||--o{ ShippingOption : has
    ServiceZone ||--o{ GeoZone : has

    ShippingProfile ||--o{ ShippingOption : has
    ShippingOption ||--o{ ShippingOptionRule : has
    ShippingOption ||--o{ Fulfillment : has
    ShippingOption }o--|| ShippingOptionType : has
    ShippingOption }o--o| FulfillmentProvider : uses

    Fulfillment ||--o{ FulfillmentItem : has
    Fulfillment ||--o{ FulfillmentLabel : has
    Fulfillment }o--o| FulfillmentAddress : delivery_to
    Fulfillment }o--o| FulfillmentProvider : uses

    FulfillmentSet {
        varchar id PK
        text name
        text type
        jsonb metadata
        timestamp created_at
        timestamp updated_at
        timestamp deleted_at
    }

    ServiceZone {
        varchar id PK
        text name
        varchar fulfillment_set_id FK
        jsonb metadata
        timestamp created_at
        timestamp updated_at
        timestamp deleted_at
    }

    GeoZone {
        varchar id PK
        enum type
        text country_code
        text province_code
        text city
        varchar service_zone_id FK
        text postal_expression
        jsonb metadata
        timestamp created_at
        timestamp updated_at
        timestamp deleted_at
    }

    ShippingOption {
        varchar id PK "so_xxx"
        text name
        enum price_type
        varchar service_zone_id FK
        varchar shipping_profile_id FK
        varchar provider_id FK
        varchar shipping_option_type_id FK
        jsonb data
        jsonb metadata
        timestamp created_at
        timestamp updated_at
        timestamp deleted_at
    }

    ShippingProfile {
        varchar id PK
        text name
        text type
        jsonb metadata
        timestamp created_at
        timestamp updated_at
        timestamp deleted_at
    }

    ShippingOptionType {
        varchar id PK
        text label
        text description
        text code
        timestamp created_at
        timestamp updated_at
        timestamp deleted_at
    }

    ShippingOptionRule {
        varchar id PK
        text attribute
        text operator
        jsonb value
        varchar shipping_option_id FK
        timestamp created_at
        timestamp updated_at
        timestamp deleted_at
    }

    Fulfillment {
        varchar id PK "ful_xxx"
        varchar location_id
        timestamp packed_at
        timestamp shipped_at
        varchar marked_shipped_by
        varchar created_by
        timestamp delivered_at
        timestamp canceled_at
        boolean requires_shipping
        varchar provider_id FK
        varchar shipping_option_id FK
        varchar delivery_address_id FK
        jsonb data
        jsonb metadata
        timestamp created_at
        timestamp updated_at
        timestamp deleted_at
    }

    FulfillmentItem {
        varchar id PK
        varchar fulfillment_id FK
        text title
        text sku
        text barcode
        integer quantity
        varchar line_item_id
        varchar inventory_item_id
        timestamp created_at
        timestamp updated_at
        timestamp deleted_at
    }

    FulfillmentLabel {
        varchar id PK
        varchar fulfillment_id FK
        text tracking_number
        text tracking_url
        text label_url
        timestamp created_at
        timestamp updated_at
        timestamp deleted_at
    }

    FulfillmentAddress {
        varchar id PK
        text company
        text first_name
        text last_name
        text address_1
        text address_2
        text city
        text country_code
        text province
        text postal_code
        text phone
        jsonb metadata
        timestamp created_at
        timestamp updated_at
        timestamp deleted_at
    }

    FulfillmentProvider {
        varchar id PK
        boolean is_enabled
        timestamp created_at
        timestamp updated_at
        timestamp deleted_at
    }
```

---

## 9. リージョン・通貨・販売チャネル ER図

```mermaid
erDiagram
    Region ||--o{ Country : has

    Region {
        varchar id PK "reg_xxx"
        text name
        text currency_code
        boolean automatic_taxes
        jsonb metadata
        timestamp created_at
        timestamp updated_at
        timestamp deleted_at
    }

    Country {
        text iso_2 PK
        text iso_3
        text num_code
        text name
        text display_name
        varchar region_id FK
        jsonb metadata
        timestamp created_at
        timestamp updated_at
        timestamp deleted_at
    }

    Currency {
        text code PK
        text symbol
        text symbol_native
        text name
        integer decimal_digits
        numeric rounding
        timestamp created_at
        timestamp updated_at
        timestamp deleted_at
    }

    SalesChannel {
        varchar id PK "sc_xxx"
        text name
        text description
        boolean is_disabled
        jsonb metadata
        timestamp created_at
        timestamp updated_at
        timestamp deleted_at
    }

    User {
        varchar id PK "user_xxx"
        text first_name
        text last_name
        text email UK
        text avatar_url
        jsonb metadata
        timestamp created_at
        timestamp updated_at
        timestamp deleted_at
    }
```

---

## 10. 価格管理モジュール ER図

```mermaid
erDiagram
    PriceSet ||--o{ Price : has

    PriceList ||--o{ Price : has
    PriceList ||--o{ PriceListRule : has

    Price ||--o{ PriceRule : has

    PriceSet {
        varchar id PK "pset_xxx"
        timestamp created_at
        timestamp updated_at
        timestamp deleted_at
    }

    Price {
        varchar id PK "price_xxx"
        text title
        text currency_code
        numeric amount
        numeric min_quantity
        numeric max_quantity
        integer rules_count
        varchar price_set_id FK
        varchar price_list_id FK
        timestamp created_at
        timestamp updated_at
        timestamp deleted_at
    }

    PriceList {
        varchar id PK "plist_xxx"
        text title
        text description
        enum status
        enum type
        timestamp starts_at
        timestamp ends_at
        integer rules_count
        timestamp created_at
        timestamp updated_at
        timestamp deleted_at
    }

    PriceRule {
        varchar id PK
        text attribute
        text value
        integer priority
        varchar price_id FK
        timestamp created_at
        timestamp updated_at
        timestamp deleted_at
    }

    PriceListRule {
        varchar id PK
        text attribute
        text value
        varchar price_list_id FK
        timestamp created_at
        timestamp updated_at
        timestamp deleted_at
    }
```

---

## 凡例

### リレーションシップ記法

| 記法 | 意味 |
| --- | --- |
| `\|\|--o{` | 1対多（必須） |
| `}o--\|\|` | 多対1（必須） |
| `\|\|--o\|` | 1対1（オプション） |
| `}o--o{` | 多対多 |
| `}o--o\|` | 多対1（オプション） |

### カラム記法

| 記法 | 意味 |
| --- | --- |
| PK | 主キー |
| FK | 外部キー |
| UK | ユニークキー |
