0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【PlantUML】ER図の作成方法

Last updated at Posted at 2022-12-31

ファイルの作成

ER図の作成のために以下のいずれかの拡張子のファイルを作成します。

  • *.wsd
  • *.pu
  • *.puml
  • *.plantuml
  • *.iuml

ファイルの先頭に@startumlを末尾に@endumlを記述します。
@startumlに続けてダイアグラム名を記述します。

sample.pu
@startuml Sample

@enduml

以降の記述は@startuml@endumlの間に記述します。

エンティティ

エンティティは以下のように記述します。

sample.pu
@startuml Sample

entity "Entity01" as e01 {
e1_id : number
--
name : text
description : text
}

@enduml

各カラムに記号をつけたり文字装飾ができます。

sample.pu
@startuml Sample

entity "Entity01" as e01 {
  normal
  <b>bold
  <i>italic
  <u>underline
  <color:RED>red
  +green circle
  -red square
  #yellow diamond
  ~blue triangle
  *black circle
}

@enduml

またセパレータを描画できます。

sample.pu
@startuml Sample

entity "Entity01" as e01 {
  -- normal --
  == double ==
  .. dot ..
}

@enduml

各エンティティのEのマークを非表示にするにはhide circleを追記します。

sample.pu
@startuml Sample
hide circle

entity "Entity01" as e01 {
<u>e1_id : number <<generated>>
--
name : text
description : text
}

@enduml

リレーション

リレーションは以下のように記述します。

sample.pu
@startuml Sample

entity "Entity01" as e01 {
<u>e1_id : number <<generated>>
--
name : text
description : text
}
entity "Entity02" as e02 {
<u>e2_id : number <<generated>>
--
<b>e1_id : number <<FK>>
other_details : text
}
entity "Entity03" as e03 {
<u>e3_id : number <<generated>>
--
<b>e1_id : number <<FK>>
other_details : text
}

e01 ||..o{ e02
e01 |o..o{ e03

@enduml

sample.pu
@startuml Sample

e01 ||..|{ e02
e01 ||--|{ e03
e01 ||--o{ e04
e01 ||--o| e05

@enduml

リレーションのラインの表示方法を変更するにはskinparam linetypeを変更します。

sample.pu
@startuml Sample
skinparam linetype ortho

e01 ||..|{ e02
e01 ||--|{ e03
e01 ||--o{ e04
e01 ||--o| e05

@enduml

また次のように記述することで配置調整ができます。  

sample.pu
@startuml Sample

e01 ||-l-o{ e_left
e01 ||-u-o{ e_up
e01 ||-r-o{ e_right
e01 ||-d-o{ e_down_01
e01 ||--d-o{ e_down_02

@enduml

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?