graphviz
出自DebianWiki
graphviz是一個圖形抽象化的軟體,由AT&T所開發。您可以透過編輯dot language,表達節點的特性與節點之間的關係,就可以輕鬆的畫出一張關係圖出來,可以應用在網頁設計(SiteMap)、軟體工程、網路、資料庫...等。是個畫程式流程圖、ER 圖、關係圖不可多得的好幫手。現已支援中文UTF-8。
安裝graphviz
#apt-get install graphviz
簡單的畫ER model範例,使用中文必須指定TTF字型路徑,fontsize可不指定。 用/**/括起來的部份為註解。
graph G{
/*設定node基本屬性*/
node[shape=box,fontname="/usr/share/fonts/truetype/fireflysung.ttf",fontsize=12];course;institude;student;許功蓋;
node[shape=diamond,style=filled,color=yellow,fontsize=12];"C-I";"I-S";"C-S";
node[shape=ellipse,style=filled,color=lightgrey,fontsize=12];s_id;s_name;s_major;c_id;c_name;i_id;i_name;
/*設定node之間的關係*/
course--"C-I";
"C-I"--institude;
institude--"I-S";
"I-S"--student;
course--"C-S";
"C-S"--student;
/*node DB attribute*/
student--s_id;
student--s_name;
student--s_major;
course--c_id;
course--c_name;
institude--i_id;
institude--i_name;
institude--許功蓋 [fontname="/usr/share/fonts/truetype/fireflysung.ttf",label="測試",fontsize=12];
fontname="/usr/share/fonts/truetype/fireflysung.ttf"
label = "\n\n用Graphviz做的第一個ER model圖\n支援UTF-8喔!";
fontsize=12;
}
此種ER model為無向性,所以使用graphviz 內的neato來產生png圖檔,支援的圖檔格式很多。
neato -Tpng neatotest.dot -o neatotest.png
範例產生的ER model圖檔
http://www.graphviz.org - graphviz 官方網站,內有豐富說明文件與範例。
![[Main Page]](/upload/4/49/Debian_taiwan_out.png)