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?

PlantUMLの概要

PlantUMLは、UML(統一モデリング言語)図をテキストベースで簡単に作成できるツールです。UML図を作成するためのシンプルな構文を使用し、視覚的に理解しやすい図を生成できます。以下に、PlantUMLの基本的な使い方と、架空のテーブルを用いた2つの簡単な例を紹介します。

PlantUML公式サイト

PlantUMLの基本構文

PlantUMLの基本構文は以下のようになります:

@startuml
Bob -> Alice : hello
@enduml

この構文では、「Bob」から「Alice」へのメッセージ「hello」を示すシンプルなシーケンス図が生成されます。

image.png

スター・スキーマの例

スター・スキーマはデータウェアハウスにおける代表的なスキーマです。中心に配置された事実テーブル(Factテーブル)と、それを取り囲むように配置された複数の次元テーブル(Dimensionテーブル)から構成されます。事実テーブルには数値データが格納され、次元テーブルにはそれを説明するための詳細データが格納されます。

以下は、架空の販売データベースを用いたスター・スキーマのUML例です。
「*」 で主キーを表し、「#」で外部キーを表しています。

@startuml
entity Fact_Sales {
  * sales_id : int
  # product_id : int 
  # customer_id : int
  # store_id : int
  # date_id : int
  + sales_amount : float
  + quantity_sold : int
}

entity Dimension_Product {
  * product_id : int
  + product_name : string
  + category : string
  + price : float
}

entity Dimension_Customer {
  * customer_id : int
  + customer_name : string
  + region : string
  + birthdate : date
}

entity Dimension_Store {
  * store_id : int
  + store_name : string
  + location : string
}

entity Dimension_Date {
  * date_id : int
  + date : date
  + month : string
  + year : int
}

Fact_Sales }-- Dimension_Product
Fact_Sales }-- Dimension_Customer
Fact_Sales }-- Dimension_Store
Fact_Sales }-- Dimension_Date
@enduml

image.png

データボルトの例

データボルトは、データウェアハウスの設計手法の一つで、柔軟性とスケーラビリティを重視したモデルです。データボルトは、Hub、Link、Satelliteの3つの主要な構成要素から成り立ちます。

Hub: 主キー情報を保持し、ビジネスエンティティを識別します。
Link: Hub間のリレーションシップを保持します。
Satellite: HubやLinkに関連する属性情報を保持します。
以下は、架空の顧客管理データベースを用いたデータボルトのUML例です。

@startuml
entity Hub_Customer {
  * customer_id : int
  + customer_key : string
  + load_date : date
  + record_source : string
}

entity Hub_Product {
  * product_id : int
  + product_key : string
  + load_date : date
  + record_source : string
}

entity Link_Customer_Product {
  * link_id : int
  # customer_id : int
  # product_id : int
  + load_date : date
  + record_source : string
}

entity Satellite_Customer {
  * customer_id : int
  + customer_name : string
  + region : string
  + birthdate : date
  + load_date : date
  + record_source : string
}

entity Satellite_Product {
  * product_id : int
  + product_name : string
  + category : string
  + price : float
  + load_date : date
  + record_source : string
}

Hub_Customer }-- Link_Customer_Product
Hub_Product }-- Link_Customer_Product
Hub_Customer }-- Satellite_Customer
Hub_Product }-- Satellite_Product
@enduml

image.png

まとめ

PlantUMLを使用すると、テキストベースで簡単にUML図を作成できます。この記事では、PlantUMLの基本的な使い方と、架空のテーブルを用いた2つのUMLモデリング例(スター・スキーマとデータボルト)を紹介しました。これらの例を参考にして、実際のプロジェクトでPlantUMLを活用してみてください。

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?