こちらのサイトではDRUPAL10に関連する記事を掲載しています。
この記事はこちらのサイトから引用させていただきました

設計 | PlantUMLでER図を作成 - わくわくBank
データの関連性を理解するのに役立つのがER図です。ER図は、「エンティティ」「アトリビュート」「リレーション」「カーディナリティ」で構成されます。ここでは、PlantUMLを利用してER図を書く方法について整理します。
PlantUMLの公式リファレンスマニュアルです
https://pdf.plantuml.net/PlantUML_Language_Reference_Guide_ja.pdf
データの関連性を理解するのに役立つのがER図です。
ER図は、「エンティティ」「アトリビュート」「リレーション」「カーディナリティ」で構成されます。
ここでは、PlantUMLを利用してER図を書く方法について整理します。
エンティティ / アトリビュート
エンティティ
アトリビュート(エンティティに関する情報)
は以下のように定義できます。
@startuml
!define TRANSACTION CAE7F2
entity users as "users\nユーザー" <<T,TRANSACTION>> {
+ id INT(10) [PK]
--
- xxx_01 BIGINT(30) [あああ]
# xxx_02 TINYINT(1) [いいい]
* xxx_03 FLOAT
~ xxx_04 DOUBLE
xxx_05 VARCHAR(255)
xxx_06 TEXT
xxx_07 DATE
xxx_08 DATETIME
xxx_09 TIMESTAMP
xxx_10 GEOMETRY
xxx_11 JSON
}
@enduml


エンティティをグループ化
エンティティをpackageでグループ化できます。
@startuml
package database <<Database>> {
entity entity01 {}
entity entity02 {}
}
package folder <<folder>> {
entity entity10 {}
entity entity11 {}
}
package rectangle <<rectangle>> {
entity entity30 {}
}
package frame <<frame>> {
entity entity40 {}
}
@enduml


リレーション / カーディナリティ
リレーション
カーディナリティ(多重度)
は以下のように定義できます。
@startuml
entity01 ||..|{ entity02
entity03 ||--|{ entity04
entity05 ||--o{ entity06
entity07 ||--o| entity08
@enduml


配置調整
l
u
r
d
でエンティティの位置調整ができます。
@startuml
entity01 ||-l-o{ entity_left
entity01 ||-u-o{ entity_up
entity01 ||-r-o{ entity_right
entity01 ||-d-o{ entity_down_01
entity01 ||--d-o{ entity_down_02
@enduml


別ファイルで管理
「エンティティの定義」「リレーションの定義」を別ファイルで管理することができます。
エンティティ
entity.puml@startuml
!define MASTER F9DFD5
!define TRANSACTION CAE7F2
entity users as "users\nユーザー" <<T,TRANSACTION>> {
+ id INT(10) [PK]
--
name VARCHAR(30) [名前]
# country_id [FK]
created_at TIMESTAMP
updated_at TIMESTAMP
}
entity posts as "posts\n記事" <<T,TRANSACTION>> {
+ id INT(10) [PK]
--
title VARCHAR(30) [タイトル]
body VARCHAR(255) [記事]
# user_id [FK]
created_at TIMESTAMP
updated_at TIMESTAMP
}
entity countries as "countries\n国" <<M,MASTER>> {
+ id INT(10) [PK]
--
name VARCHAR(50) [国名]
created_at TIMESTAMP
updated_at TIMESTAMP
}
@enduml
リレーション
!include entity.puml
で先述したエンティティの定義を読み込みます。
@startuml
!include entity.puml
users }|-l-|| countries
users ||-r-o{ posts
@enduml



この記事またはDrupalに関するご質問がございましたら、お気軽にお問い合わせください。