PHP Classes
elePHPant
Icontem

dia2sql: Class to generate SQL files from DIA diagrams.

Recommend this page to a friend!
  Info   View files View files (4)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2002-08-06 (14 years ago) RSS 2.0 feedNot enough user ratingsTotal: 1,174 All time: 3,104 This week: 1,091Up
Version License Categories
dia2sql 1.0GNU General Publi...XML, Databases
Description Author

There are few programs on Linux to convert UML diagrams into SQL instructions. This way, I decided to write a php class to read a DIA diagram and generate the correspondent SQL instructions to create DataBase.

Picture of Daniel Afonso Heisler
Name: Daniel Afonso Heisler <contact>
Classes: 5 packages by
Country: Brazil Brazil

Details
dia2sql.php

Daniel Afonso Heisler
IT department - UNIVATES
daniel@univates.br

1. Introduction:
   There are few programs on Linux to convert UML diagrams into SQL instructions. This way, I decided to write a php class to read a DIA diagram and generate the correspondent SQL instructions to create DataBase.


2. Features:
   DIA (http://hans.breuer.org/dia) is a gtk+ program to create diagrams. It can be used to draw many sort of diagrams, including UML diagrams. However, as the most of programs, DIA generates only the diagram, It doesn't export SQL instructions.
   The dia2sql.php class is a tool that convert this UML diagram into SQL. As Dia files are saved in XML format, is possible to read these files and create a DataBase structure easily.
   This first version supports only PostgreSQL.

3. Configuration:
   In order to use the class the right way is needed to foolow some conventions during the diagram creation. This first version supports only classes (tables) and associations (references). You gotta save the diagram in XML format.

   3.1 Classes:
       - The class name is always the table name.
       - The table fields are inserted as attributes.
       - The attributes (fields) can be:
         '+' -> 'Public': Simple field.
         '#' -> 'Protected': Primary key;
         '-' -> 'Privated': Creates an individual index and another one grouped with all others marked with this option.
         ' ' -> 'Implementation': Creates a unique index grouped with another ones marked with this option and one index to each individual field;

       - The Option Class Scope is used to define whether the field is a sequence or not;

   3.2 Associations:
       - The references are done with "Associate to UML" option. You must link two fields of tables and show the origin and the target of the relation. It's important to stablish the link of the fields exactly at the points near of each field.


4. Example:
   Inside the package, there is a file called example.dia that can be either edited by DIA or converted into SQL instructions. In order to execute the program, type:
   # php example.php
   A "sql" directory will be created with respective files containing the Database creation instructions.

  Files folder image Files  
File Role Description
Plain text file dia2sql.php Class Class dia2sql
Accessible without login Plain text file example.dia Example Dia example diagram
Accessible without login Plain text file example.php Example Example file
Accessible without login Plain text file README Doc. README

 Version Control Unique User Downloads Download Rankings  
 0%
Total:1,174
This week:0
All time:3,104
This week:1,091Up