I was not able to succesfully install pygraphviz on my windows7 64bit enviroment but I liked Jose's idea
https://groups.google.com/d/topic/web2py/cFqD1M6rkc8/discussion, so I wrote a simple addendum to appadmin in order to show a graph representation of a database. (
update 3 Feb 2013: after Jose suggestions I was able to succesfully install pygraphviz)
It's not alternative to or a replacement of Jose's graph layout because there are substantial differences.
"db diagram" is interactive (nodes are draggable and clickable) but you cannot save it as an image (anyway it's possible to use a third party application for screenshoots).
Moreover it is customizable via css (you will find here attached a css theme for reference) and it's based on jqueryUI framewok.
The nodes contain only the table name, so we can draw the layout of a database with (moderately) numerous tables.
In order to see table data you have to click on the node. I added some infos like indexed columns (currently available only for sqlite but I think it's not hard to implement for other database engines), the list of other affected tables when we delete a row in cascade mode.
The layout (the position of nodes on the screen) is generated trough a force-directed spring algorythm. Therefore the layout is generated dinamically and it will be different each time you refresh the page.
Current main limitation (update 3 Feb 2013: limitation removed and support to multiple databases in the same application): the database must have 'db' key in application databases dictionary. In other words in our model we must have
db = DAL('sqlite://storage.sqlite',pool_size=1,check_reserved=['all'])
and not, for example,
mydb = DAL('sqlite://storage.sqlite',pool_size=1,check_reserved=['all'])
The screen dimensions are important too: the layout will be messed on small screens.
The code has been tested on latest versions of Firefox, Chrome, Opera, IE(7,8,9) and on a very limited number of databases. So please check for errors and bugs.
Installation:
1) append the code within in the attached db_diagram.py in your_application/controllers/appadmin.py file
2) put attached db_diagram.html in to your_application/views folder
3) create a new folder in your_application/static folder and name it "db_diagram"
4) in to latter put db_diagram.css, db_diagram_print.css, jquery.dbdiagram.js, pencildiagonals.png (an image create by me only for the css theme in bundle) (all these files are here attached)
update 3 Feb 2013: all the needed files, togheter with a readme, are in the attached compressed archive. I will continue to update this post, while Massimo includes "db diagram" in admin interface.
Usage:
In your appadmin page you should see a new menu item "diagram" (see image 1), click on it and you should see the layout of your "db".
That's all Folks!