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.

Mermaidを使って簡易ECサイトのER図をつくってみる

0
Posted at

はじめに

現在データベース学習中でmermaidを使用し簡易ECサイトのER図を作ってみました。

エンティティ

今回簡易的なECサイトとして以下のようなエンティティを想定しています。

ユーザー

  • ID
  • 名前

商品

  • ID
  • 名前
  • カテゴリ
  • 値段

商品カテゴリ

  • ID
  • 名前

購入商品

  • ID
  • ユーザーID
  • 商品ID
  • 購入日

ER図

エンティティをベースにER図を作成します。
マークダウン形式でER図を作成することができます。

erDiagram
  users ||--o{ user_products : "" 
  products ||--o{ user_products : ""
  products ||--o{ categories : ""
  users {
    bigint id PK
    string name "ユーザー名"
  }

  products {
    bigint id PK
    string name "商品名"
    references category_id FK 
  }

  categories {
    bigint id PK
    string name "カテゴリ名"
  }

  user_products {
    bigint id PK
    references user_id FK 
    references product_id FK 
  }

上記のようにマークダウン形式で入力することで、下記のようなER図を生成可能。

まとめ

今回はmermaidでER図を作成してみました。
そのほかの図も作成することができるようなので試してみたいです。

参考情報

  • mermaid公式サイト

  • ER図作成参考情報

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?