Sunday, March 13, 2011

Generating ER Diagram from Postgresql on ubuntu

Generating ER Diagram from Postgresql on ubuntu

Their are two ways that you can do it
1) You can create .png which is shown on step 4
2) Or else you ca use .dia file in Dia which is more convince
Step 1 to 3 is Common 4 and 5 are optional to each other as mention above

Installation Step :

* 1st step:
Install postgresql_autodoc from synaptic manager first
+Link to AutoDoc Home Page : http://www.rbt.ca/autodoc/

* 2nd step:

jam@jam-desktop:~/Desktop/test$ postgresql_autodoc -h localhost -d mydb -u=jam --password=jam

-h Hostname where server is running (e.g.: localhost)
-d DatabaseName (e.g.: mydb)
-u Postgres User (e.g.: jam)
-p Postgres User password (e.g.: jam)

The above command will generate lots of files in different format (dia, html, dot).
Of particular interest will be the dot file which can be used to create any kind of image file (gif, png, jpeg, etc.)

* 3rd step:

Install Graphviz Utility :
jam@jam-desktop:~$ sudo apt-get install graphviz
+ Link to graphviz : http://www.graphviz.org/

* 4th step:

The dot utility will allow you to convert this mydb.dot file into a png file
+ jam@jam-desktop:~/Desktop/test$ dot -Tpng mydb.dot > mydb.png

* 5th step:

Or else you can Directly Use the .dia file to with Dia and Cutmize the Vie to Output with your requirements

Hope this will help you
Regards

1 comment: