PHP Classes


Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in Bookmark in
  Classes of Daniel Afonso Heisler  >  dia2sql  >  README  >  Download  
Role: Documentation
Content type: text/plain
Description: README
Class: dia2sql
Class to generate SQL files from DIA diagrams.
Author: By
Last change:
Date: 13 years ago
Size: 2,270 bytes


Class file image Download

Daniel Afonso Heisler
IT department - UNIVATES

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 ( 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.