mjl blog
feed
May 24th 2016

Printing a database schema on paper

Understanding new information requires an overview of all relevant information. Laying out all the details can help. Like when you’re trying to understand a database schema, with lots of relations. It can help to see it on paper, you can point and write down notes.

This post is mostly a note to myself. To remember how to get a database schema printed. In this case for a MySQL database. I’m working on MacOSX by the way.

First, create a dot file. I used Sequel Pro to connect to the MySQL database. It has an option to Export data, where you can choose “dot file” as a format.

Second, convert the dot file to a Postscript file. You can do this with the trusty old program “dot”. I already had it installed. It’s probably from the Graphviz package. Run a command like this one:

dot -Tps:cairo:cairo -Kfdp yourdatabase.dot >yourdatabase.ps

Note: I had to use the cairo output. Otherwise, I only saw a tiny part of the database schema. Also, the “fdp” layout algorithm produced more insightful graphs for my database.

Third, convert the Postscript file to pdf. The tool comes builtin with MacOSX:

pstopdf yourdatabase.ps
# you should now have a file yourdatabase.pdf

Fourth, use pdfposter to split the single page into several pages. I had to install the program, it’s in port (“port install pdfposter”):

pdfpost -m a4 -p a2 yourdatabase.pdf yourdatabase.a2.pdf

Fifth, print the thing! For me, the generated PDF on A2 contained blank pages. So you may need to make a selection of pages when printing.

That’s it.

Comments