LoginSignup
2
3

PlantUMLでER図を描いてみる

Last updated at Posted at 2021-01-24

必要なもの

  • エディタ
    • VSCode
  • VSCodeプラグイン

環境構築

DockerでPlantUMLが動く環境を構築する。

PlantUML Serverを起動

docker run -d --name plantuml_server -p 8080:8080 plantuml/plantuml-server:jetty

VSCodeの設定

プラグインのPlantUMLにカーソルを合わせて右クリック→Extension Settings。

設定項目
Plantuml: Render PlantUMLServer
Plantuml: Server http://localhost:8080

単一テーブルを作成する

@startuml ""

Class "order:注文" as order <<T,FFAA00)>> {
  + order_id: 注文ID [PK]
  ---
  order_date: 注文日
  product_code: 商品コード [FK]
  customer_code: 顧客コード [FK]
  quantity: 数量
  created_at: 作成日
  updated_at: 更新日
}

@enduml

スクリーンショット 2021-01-24 20.17.53.png

プレビューはMacだと「オプション + D」で開きます。

複数テーブルを作成してリレーションを引いてみる


@startuml ""

!include ./order.pu
!include ./customer.pu
!include ./product.pu

product "1..*"--ri--"1" order
order "1..*"--ri--"1" customer

@enduml

スクリーンショット 2021-01-24 20.18.49.png

レイアウトの方向

方向 キーワード
up
do
le
ri

参考

2
3
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
2
3