GraphVizを利用してER図を作成してみる

dotファイルを作成

digraph sample {

    graph [rankdir=LR];
    node [shape=record,fontsize=8,width=2.0];
    edge [fontsize=8];

    # エンティティテーブルを定義
    sample [label="[Sample]|{{id|name}|{ID|名前}}"];
    test [label="[Test]|{{id|sample_id|message}|{ID|サンプルID|メッセージ}}"];

    # エンティティ関連性を定義
    sample -> test [label="sample_id=id"];
}

画像ファイルを生成

dot -T png -o sample.png sample.dot

を実行すると画像ファイルが生成される