SQL Diagram creation: Difference between revisions

From OpenPetra Wiki
Jump to navigation Jump to search
Line 1: Line 1:
== Summary ==
This page describes the sql2diagram tool, and how to use it for OpenPetra.org.
== sql2diagram ==
== sql2diagram ==
We wrote this tool a while ago in C/C++ and uploaded it to sourceforge: http://sql2diagram.wiki.sourceforge.net/
We wrote this tool a while ago in C/C++ and uploaded it to sourceforge: http://sql2diagram.wiki.sourceforge.net/
Line 46: Line 49:
** a GPL path finding implementation in C: http://marathon.svn.sourceforge.net/viewvc/marathon/trunk/Source_Files/GameWorld/pathfinding.cpp
** a GPL path finding implementation in C: http://marathon.svn.sourceforge.net/viewvc/marathon/trunk/Source_Files/GameWorld/pathfinding.cpp
** see also http://lib2dp.sourceforge.net/ 2DPathfinder is a C library for performing fast pathfinding on 2D maps.
** see also http://lib2dp.sourceforge.net/ 2DPathfinder is a C library for performing fast pathfinding on 2D maps.
== How to use sql2diagram for OpenPetra.org ==
See a sample result here: [http://openpetraorg.sourceforge.net/dbdoc/img/img_AccountsPayable.html?a_ap_document diagram for the Accounts Payable sub system]
See the file themed.prj in OpenPetra\db\doc; that contains already a collection of tables. You might also copy the table names from the file master_alltables.prj in the same directory.
Then you run <code>nant dbdoc</code> to generate the diagram file (extension .dia). You then can edit that with the [http://live.gnome.org/Dia/Download dia editor] (available for Linux and Windows). First, the tables are all on the invisible layer. See the instructions on the [http://sql2diagram.wiki.sourceforge.net/ sql2diagram page] how to copy the tables to the front layer, and then to arrange the tables. Next time you run <code>nant dbdoc</code> the constraint lines will be inserted. Please try to make them look ok by moving the lines and inserting new segments.

Revision as of 13:10, 18 Haziran 2009

Summary

This page describes the sql2diagram tool, and how to use it for OpenPetra.org.

sql2diagram

We wrote this tool a while ago in C/C++ and uploaded it to sourceforge: http://sql2diagram.wiki.sourceforge.net/

functionality:

  • it reads the SQL tables and attributes from the SQL file with all the CREATE TABLE statements
  • it generates HTML documentation
  • it is able to generate diagrams for the DIA program (http://live.gnome.org/Dia)
  • it generates an HTML map for the diagram png file, and links to it from the HTML documentation

The generation of the HTML documentation works fine.

For the current results, check http://openpetraorg.sourceforge.net/dbdoc; There is a diagram for the Accounts Payable sub system: http://openpetraorg.sourceforge.net/dbdoc/img/img_AccountsPayable.html?a_ap_document

diagrams

There are some problems with generating the diagrams. On the one hand it allows manual moving of the tables and connections in the dia editor, and the sql2diagram tool should pick up the manual positions and reuse them. But on the other hand, it is quite tedious to move the tables and foreign key constraints all by hand.

Task 1: Use the new Database tools, instead of the ER shapes

Database shapes were only added recently to dia, and might look better than the ER shapes we are using currently.

Issues to consider: how to show which fields are part of a foreign key? At the moment, we print FK at the back of the row that describes the field name and type.

Task 2: Do an automatic layout of the tables and connections

Alternatives:

Some discussions and first hints:

So my approach to Task 2 would be to use some good algorithms when arranging the diagram, and make sure the generated diagram has the tables in the best position (most referenced tables in the centre, tables that are most linked to each other closest to each other), and the linking constraints are not crossing any tables, and are still possible to be read.

How to use sql2diagram for OpenPetra.org

See a sample result here: diagram for the Accounts Payable sub system

See the file themed.prj in OpenPetra\db\doc; that contains already a collection of tables. You might also copy the table names from the file master_alltables.prj in the same directory.

Then you run nant dbdoc to generate the diagram file (extension .dia). You then can edit that with the dia editor (available for Linux and Windows). First, the tables are all on the invisible layer. See the instructions on the sql2diagram page how to copy the tables to the front layer, and then to arrange the tables. Next time you run nant dbdoc the constraint lines will be inserted. Please try to make them look ok by moving the lines and inserting new segments.