[数据库设计]使用Graphviz画ER图-阿里云开发者社区

开发者社区> 开发与运维> 正文

[数据库设计]使用Graphviz画ER图

简介:

Netkiller Developer 手札

November 15, 2008

MrNeo Chan陈景峰

 


中国广东省深圳市宝安区龙华镇
518109
+86 755 29812080
+86 755 29812080

 

版权 © 2008, 2009, 2010, 2011 Netkiller(Neo Chan). All rights reserved.

版权声明

转载请与作者联系,转载时请务必标明文章原始出处和作者信息及本声明。

 

文档出处: http://netkiller.sourceforge.net/ | http://netkiller.github.com

文档最近一次更新于 Mon Dec 5 09:39:01 UTC 2011

 

 

to see all available graphviz packages.

$ apt-cache search graphviz |grep ^g
graphviz - rich set of graph drawing tools
graphviz-dev - transitional package for graphviz-dev rename
graphviz-doc - additional documentation for graphviz

$ apt-cache search graphviz |grep Graphviz
dot2tex - Graphviz to LaTeX converter
libgraph-easy-perl - Perl module to convert or render graphs (as ASCII, HTML, SVG or via Graphviz)
python-pydot - Python interface to Graphviz's dot
python-pygraphviz - Python interface to the Graphviz graph layout and visualization package
python-yapgvb - Python bindings for Graphviz, using Boost.Python
xdot - interactive viewer for Graphviz dot files
			

 

$ sudo apt-get install graphviz
			

Test, A "Hello World" example made by giving the command:

echo "digraph G {Hello->World}" | dot -Tpng >hello.png


$ cat erd.gv
digraph g {
graph [
rankdir = "LR"
];
node [
fontsize = "16"
shape = "ellipse"
];
edge [
];

"user" [
        label = "User| <id> id|username|password|last|status"
        shape = "record"
];

"profile" [
        label = "Profile| <id> id | name | sex | age | address | icq | msn"
        shape = "record"
];

user:id->profile:id [label="1:1"];

"category" [
        label = "Category| <id> id | <pid> pid | name | status"
        shape = "record"
];

category:pid->category:id [label="1:n"];

"article" [
        label = "Article| <id> id| <user_id> user_id | <cid> category_id | title | content | datetime | status"
        shape = "record"
];

article:user_id->user:id [label="1:n"];
article:cid->category:id [label="1:n"];

"feedback" [
        label = "Feedback| <id> id| <user_id> user_id | <article_id> article_id | title | content | datetime | status"
        shape = "record"
];

feedback:user_id->user:id [label="1:n"];
feedback:article_id->article:id [label="1:n"];

}
			
			
			
$ dot -Tpng erd.gv > erd.png
			


 

版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。

分享:
开发与运维
使用钉钉扫一扫加入圈子
+ 订阅

集结各类场景实战经验,助你开发运维畅行无忧

其他文章