ER図
(Entity-Relationship Diagram)
サンプル
@startuml
entity customer
entity order
entity product
entity order_item
customer ||--o{ order : places
order ||--o{ order_item : contains
product ||--o{ order_item : lists
@endumlPlantUMLソース
@startuml
entity customer
entity order
entity product
entity order_item
customer ||--o{ order : places
order ||--o{ order_item : contains
product ||--o{ order_item : lists
@enduml全体の設定
タイトル
タイトルを定義できます。
title 新基盤構築計画PlantUMLソース
@startuml
title 新基盤構築計画
entity customer
entity order
entity product
entity order_item
customer ||--o{ order : places
order ||--o{ order_item : contains
product ||--o{ order_item : lists
@endumlヘッダ
ヘッダを定義できます。
header 新基盤構築計画PlantUMLソース
@startuml
header 新基盤構築計画
entity customer
entity order
entity product
entity order_item
customer ||--o{ order : places
order ||--o{ order_item : contains
product ||--o{ order_item : lists
@endumlフッタ
フッタを定義できます。
footer フッタPlantUMLソース
@startuml
footer フッタ
entity customer
entity order
entity product
entity order_item
customer ||--o{ order : places
order ||--o{ order_item : contains
product ||--o{ order_item : lists
@endumlキャプション
キャプションを定義できます。
caption キャプションPlantUMLソース
@startuml
caption キャプション
entity customer
entity order
entity product
entity order_item
customer ||--o{ order : places
order ||--o{ order_item : contains
product ||--o{ order_item : lists
@endumlすべて組み合わせると…
PlantUMLソース
@startuml
title 新基盤構築計画
header 新基盤構築計画
footer フッタ
caption キャプション
entity customer
entity order
entity product
entity order_item
customer ||--o{ order : places
order ||--o{ order_item : contains
product ||--o{ order_item : lists
@endumlエンティティ
エンティティを定義できます。
entity customer {}PlantUMLソース
@startuml
entity customer {}
@endumlカラム
entity要素の中にカラムを定義できます。
entity customer {
column1
}PlantUMLソース
@startuml
entity customer {
column1
}
@endumlプライマリキー
+ column1 [PK]PlantUMLソース
@startuml
entity customer {
+ column1 [PK]
}
@endumlフォーリンキー
# column2PlantUMLソース
@startuml
entity customer {
+ column1 [PK]
__
# column2
}
@endumlユニークインデックス
* column2PlantUMLソース
@startuml
entity customer {
+ column1 [PK]
__
* column2
}
@endumlその他
それ以外に下記の記号を使用する事も可能です。
- column2
~ column3PlantUMLソース
@startuml
entity customer {
+ column1
__
- column2
~ column3
}
@endumlリレーション
1 – (0.1)
entity1 ||--o| entity2PlantUMLソース
@startuml
entity entity1 {}
entity entity2 {}
entity1 ||--o| entity2
@enduml1 - 1
entity1 ||--|| entity2PlantUMLソース
@startuml
entity entity1 {}
entity entity2 {}
entity1 ||--|| entity2
@enduml1 – (0.n)
entity1 ||--o{ entity2PlantUMLソース
@startuml
entity entity1 {}
entity entity2 {}
entity1 ||--o{ entity2
@enduml1 – (1.n)
entity1 ||--|{ entity2PlantUMLソース
@startuml
entity entity1 {}
entity entity2 {}
entity1 ||--|{ entity2
@enduml(0.1) – 1
entity1 |o--|| entity2PlantUMLソース
@startuml
entity entity1 {}
entity entity2 {}
entity1 |o--|| entity2
@enduml(0.n) – 1
entity1 }o--|| entity2PlantUMLソース
@startuml
entity entity1 {}
entity entity2 {}
entity1 |o--|| entity2
@enduml(1.n) – 1
entity1 }|--|| entity2PlantUMLソース
@startuml
entity entity1 {}
entity entity2 {}
entity1 }|--|| entity2
@enduml位置調整
上
entity1 ||-u-|| entityUpPlantUMLソース
@startuml
entity entity1 {}
entity entityUp {}
entity1 ||-u-|| entityUp
@enduml下
entity1 ||-d-|| entityDownPlantUMLソース
@startuml
entity entity1 {}
entity entityDown {}
entity1 ||-d-|| entityDown
@enduml左
entity1 ||-l-|| entityLeftPlantUMLソース
@startuml
entity entity1 {}
entity entityLeft {}
entity1 ||-l-|| entityLeft
@enduml右
entity1 ||-r-|| entityRightPlantUMLソース
@startuml
entity entity1 {}
entity entityRight {}
entity1 ||-r-|| entityRight
@enduml罫線
カラムの間を罫線で区切る事ができます。
実線
--PlantUMLソース
@startuml
entity customer {
id
--
text
}
@enduml__PlantUMLソース
@startuml
entity customer {
id
__
text
}
@enduml点線
..PlantUMLソース
@startuml
entity customer {
id
..
text
}
@endumlノート
左側
note left : ノートPlantUMLソース
@startuml
entity customer {
id
__
text
}
note left : ノート
@enduml右側
note right : ノートPlantUMLソース
@startuml
entity customer {
id
__
text
}
note right : ノート
@enduml上側
note top : ノートPlantUMLソース
@startuml
entity customer {
id
__
text
}
note top : ノート
@enduml下側
note bottom : ノートPlantUMLソース
@startuml
entity customer {
id
__
text
}
note bottom : ノート
@enduml複数行の場合
この機能は、ノートを右側に配置する場合、左側に配置する場合、上側に配置する場合、下側に配置する場合でも使用できます。
尚、このサイトでは右側のみ紹介しています。
note right
クラスの右側に注釈1
クラスの右側に注釈2
end notePlantUMLソース
@startuml
entity customer {
id
__
text
}
note right
クラスの右側に注釈1
クラスの右側に注釈2
end note
@enduml行コメント
'から始まる行は行コメントとして扱われます。
ブロックコメント
/*から*/まではブロックコメントとして扱われます。
:::warning
注意: ただし、行頭以外に/*を置いた場合にブロックコメントとして認識されないようです。
また行の途中で*/を記載してもその行の最後までブロックコメントとして処理されるようです。
:::