By Colin Fox - cfox@cfconsulting.ca
Required packages: graphviz, xsltproc, convert.
I was disappointed with the current state of reverse-engineering diagram tools, so I decided to write my own. I started with the excellent XMLtoDDL program by Scott Kirkwood(http://xml2ddl.berlios.de/). At the time, his downloadXml.py file didn't output the schema name that a table belonged to, so I had to modify my private copy for that.
I also found that I really liked the graphviz diagramming program, and felt that it had a great logic for laying out elements. So the task then became creating an XSL stylesheet that would convert the XML output of downloadXml into a graphviz input file. I also wanted to make sure that there were "no dead crows" -- having the crows-feet right side up makes the diagram a lot more readable in my humble opinion.
To create a diagram, you create an XML file that describes what tables and schemas you want to be a part of the diagram. You can choose schemas, tables or both.
Here is the XML file for the above diagram.
<?xml version="1.0"?> <autograph:report xmlns:xi="http://www.w3.org/2003/XInclude" xmlns:autograph="http://cfconsulting.ca/autograph/1.0" > <autograph:graphparams> <autograph:tablemode name="simple" /> </autograph:graphparams> <autograph:includeschemas> <autograph:schema name="financial" /> <autograph:schema name="general" /> </autograph:includeschemas> <autograph:includetables> <autograph:table schema="discussion" table="comments" /> </autograph:includetables> <xi:include href="./auto_autographtest.xml" /> </autograph:report>
The graphparams section is for specifying either "simple" or "detailed". A simple graph is one that has a box for each table, and crows feet joining them. A detailed graph actually has all the fields visible per table, so creates a much larger and harder to read graph. I don't use this mode very much.
The includeschemas section is to specify which schemas you wish to include in the diagram. All tables in the listed schemas will be diagrammed. This section may be removed if you only want to specify individual tables.
The includetables section is where you list the individual tables you want included. You specify the schema and table.
Next is a diagram where we just include the financial schema, and nothing else. One other thing to note about these diagrams -- if a table is referenced but it is not part of your schema or table selection, it will still appear in th e diagram. This is why the "people" table appears in the following diagram, even though the people table isn't in the financial schema. This is a feature of graphviz which I find useful, so I didn't try to eliminate it.