LoginSignup
1
0

More than 5 years have passed since last update.

[other] ER図の作成

Posted at

概要

erdot を使用した ER図の作成

環境

macOS High Sierra: 10.13.6

Golang install

$ brew install go
・

$ go version
go version go1.12 darwin/amd64

Graphviz install

$ brew install graphviz
・

$ echo $?
0

$ dot -V
dot - graphviz version 2.40.1 (20161225.0304)

erdot install

$ go get github.com/twinbird/erdot
  # => 出力はなにも出ない。。。

$ echo $?
0

$ ls -ltr
  # go という directory が作成されている
・
drwxr-xr-x    4 hoge  staff     128  3 11 18:42 go

$ find go -name erdot
go/bin/erdot
go/src/github.com/twinbird/erdot

# erdot をパスの通った directory に移動
$ cp -v go/bin/erdot ~/bin


# test
$ mkdir -pv ~/tmp/erdot

$ cat << "EOF" > test.erdot
// estimate print system

# Tables

// master

user (ユーザ情報)
    id (ID) INTEGER PRIMARY KEY
    name (ユーザ名) VARCHAR(100) NOT NULL

employees (従業員)
    id (ID) INTEGER PRIMARY KEY
        user_id (ユーザID) INTEGER NOT NULL
    last_name (姓) VARCHAR(30) NOT NULL
    first_name (姓) VARCHAR(30) NOT NULL

# Relations
employees.user-id 1-1 user.id
EOF

$ erdot system.erdot | dot -Tpng -o output.png
$ open output.png
# => 正しく表示されていることを確認

$ erdot test.erdot | dot -Tpng -o output.png
# => 正しく表示されていることを確認

資料

1
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
1
0