Drawing the database schema

mooffie - October 18, 2007 - 12:33

Drupal 6 comes with a DB schema, which makes it possible now to programmatically draw a graph of the relationships among the tables.

Utilizing graphviz I played with the possibilities yesterday and here's a thumbnail of the result. Full-size versions can be found here.

The '.svg' and '.html' versions display a descriptive tooltip when you hover the mouse over fields.

Many tables are linked by "node.nid" or "user.uid" and in order to not clutter the display with too many "snakes" I colored "node.nid" links in green and "user.uid" ones in red. So wherever you see red or green lines don't bother following them with your eyes: you already know where they lead to.

Note that everything is done automatically. No tweaking is done by hand. The script uses drupal_get_schema() to learn about Drupal and a 'Makefile' is used to automate the generation of the various output files.

Fantastic! Been waiting for

gpk - October 18, 2007 - 13:49

Fantastic! Been waiting for this for years. (Well, months at least!)

Many thanks for making this.

gpk
----
www.alexoria.co.uk

...

mooffie - October 18, 2007 - 14:46

Thanks.

I should mention here the efforts made by webchick, add1sun, bjaspan, and others, to make all this possible (and easy (and fun! :-)).

OK, thanks to the whole team

gpk - October 18, 2007 - 16:29

OK, thanks to the whole team then ;-)

In fact this is so good that it really ought to be featured as a News item - finally everyone can understand the Drupal DB structure. A page in the handbook would simply not be enough to mark this giant leap for Drupaldom! Also found the Schema module. Arguably should be in core since it could be a vital admin tool (particularly at upgrade time ...!) Looks fantastic :-D

gpk
----
www.alexoria.co.uk

Awesome, and thanks!

Michael Curry - January 7, 2010 - 20:35

Thanks to all for this. I've been looking for something like this for a while. 22 Thumbs Up!

Oh no! The graphs aren't

gpk - November 9, 2007 - 19:59

Oh no! The graphs aren't there any more! I should have saved them locally!

Object not found!

The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.

gpk
----
www.alexoria.co.uk

...

mooffie - November 11, 2007 - 13:30

The files are there. Try again.

I know the server sometimes go offline. I have no control over this, sorry.

Phew!

gpk - November 14, 2009 - 21:22

:-)

gpk
----
www.alexoria.co.uk

Incorporate into handbook?

skor - May 6, 2008 - 04:01

I'm not sure where would be the best place for it. Depth level, probably http://api.drupal.org but I'm not sure you can add pages there. They seem to be automatically created from the code.

Maybe somewhere at http://drupal.org/contributors-guide

Totally agree. Definitely

mgifford - December 18, 2009 - 20:54

Totally agree. Definitely needs to be there for Drupal 7 as well when it is released.

http://www.typo.co.il/~mooffie/tmp/schemagraph/output/schemagraph-2007-1...

 
 

Drupal is a registered trademark of Dries Buytaert.