tedia2sql 1.2.8
What is tedia2sql?
It is a tool that allows you to create a database ERD in
Dia
(using the UML shape toolset), then to convert that ERD into a
SQL DDL script for multiple databases. Traditionally, to be
able to do these things, you've needed to have a Win32 OS
installed. But because Dia is available for Unices, and because
my Perl script works on Unices, this means that you can now
create ERDs that generate SQL DDL for your database -- all
without ever rebooting into Win32! The best part is, if you're
stuck using Win32, tedia2sql will still work for you,
because it has been modified to run under popular Win32
Perl environments (even non-Cygwin environments, although
Cygwin will naturally work).
Help Me Add Database Support to tedia2sql
You do not need to be a Perl coder to code support for new
databases! A good working knowledge of the SQL DDL for the
flavour you're interested in, and merely a cursory knowledge of
C (or Perl or Java or any C-like language) should be all you
need. Please actually look at the source code and see if you
can understand it. You might be surprised.
If all that still makes you too nervous, just allow me to send
you a SQL script generated by tedia2sql and run it against a
test database, and report back errors.
Short History of tedia2sql
I originally named tedia2sql "dia2sql" -- a mistake. There was
already a script called dia2sql by Alexander Troppman and
tedia2sql has almost nothing to do with the original dia2sql,
which you can probably tell by reviewing the source. It is
also incompatible with the original dia2sql in that Dia UML
diagrams you've created won't result in the same SQL DDL you'd
have gotten from dia2sql.
Prerequisites for tedia2sql
(get from RPM Find dot Net)
- Dia 0.90 or newer (0.88.1 has a known problem with component stereotypes)
- expat-1.95.3 (search RPM Find for libexpat)
- Perl XML::Parser (search CPAN for xml::parser)
- Perl XML::RegExp (search CPAN for xml::regexp)
- Perl XML::DOM (search CPAN for xml::dom)
- Perl Digest::MD5 (most Perl installations should include this already)
Database Support:
- Sybase support: 95% Done (missing trigger-create for RI)
- Postgres support: Done
- Oracle support: Done
- DB/2 support: Done
- MS-SQL support: Done (needs to be tested)
- MySQL support: 95% Done (InnoDB only)
- Informix support: Not started
- Ingres support: 75% Done
Note that it should be easy to add Informix
and finish MS-SQL, MySQL, and Sybase support. All I
ask is you run the resultant script against the actual database
to make sure it doesn't complain about the SQL DDL output.
Short Feature List:
- Generates tables and views using UML Classes
- Generates foreign key constraints using UML Associations
- Generates indexes and permissions using UML Class Operations
- Generates insert statements using UML Components
- Generates special SQL (like triggers and sequences) before or
after Schema (tables) creation
- NULL, NOT NULL, DEFAULT column handling using UML Class Attribute Values
- Generated SQL DDL well-formatted and easy-to-read
- Script is GPL Perl, written in a programmer-friendly style
- Uses XML::DOM to parse the Dia XML diagram
My Own Testimonial
I've tested this script on a ~30-table schema with ~35
associations (foreign-key constraints), several inserts, and
~12 indexes, and it basically does the Right Thing, creating
valid Postgres, Oracle, DB2, and Sybase code. If you want, you
can get a
screenshot
of the big ERD as it's edited in Dia. I've purposefully made
the tables/columns very small in this screenshot to make the
screenshot small in bytesize. (Note: Sorry, I can't give you a
copy of this ERD for testing. Also, if you have a fairly large
ERD you've created in Dia that tedia2sql parses and that you
wouldn't mind the world having a copy of, please send me a
copy!)
Download the Script/Source:
Choose the Filesharing link to the left to download the source code.
There you will find versions of tedia2sql for download.
tedia2sql Documentation & Tarball-Included Files
- Brief Help
- The output of tedia2sql -h and detailed descriptions of each line.
- Using tedia2sql
- A little more in-depth information about how to
create a UML diagram in Dia that will properly parse
via tedia2sql into SQL DDL for your RDBMS.
- To-do
- The tedia2sql to-do list.
- Authors
- The tedia2sql authors and contact info page.
- Troubleshooting Guide
- I made my diagram. I ran tedia2sql on it, and everything
went dramatically wrong! Help!
- TestERD.dia Screenshot
- This is an ERD for a simple image-rating system that
I created for generating SQL DDL. Tentatively, the
destination RDBMSs for this diagram would be Sybase, PostgreSQL,
and Oracle. Once MySQL supports views, then it should be added as
a target.
- Postgres SQL DDL
- If you run the script with -i TestERD.dia -o pgsql-testerd -t postgres -d
- Sybase SQL DDL
- If you run the script with -i TestERD.dia -o sybase-testerd -t sybase -d
- Oracle SQL DDL
- If you run the script with -i TestERD.dia -o oracle-testerd -t oracle -d
- Ingres SQL DDL
- If you run the script with -i TestERD.dia -o ingres-testerd -t ingres -d
- DB/2 SQL DDL
- If you run the script with -i TestERD.dia -o db2-testerd -t db2 -d
- MySQL InnoDB SQL DDL
- If you run the script with -i TestERD.dia -o innodb-testerd -t innodb -d
Useful Links
- The Dia Homepage
- This is the place you go to find out all about Dia
- Schemamania
- This is a page dedicated to dealing with schemas.
It includes Dia-->SQL generation, but also
Dia-->C++ etc.
- Postgres SQL Database Engine
- Here you find a very high quality production-level
Open Source database engine. Commercial support is
available at pgsql dot com.
- Cygwin (Unix Tools for Win32)
- If you always wanted to run SSHd and Apache and
Bash, and you love the GNU text processing tools (and
vim and emacs and all that) and shell environment, and
you love to run a Free X server -- all this and you're
stuck on a Win32 machine, then I can't stress this
enough, DOWNLOAD AND INSTALL CYGWIN!
It is a thing of beauty running an rxvt with scrollback
buffer and Bash inside it, and typing
ls -al /cygdrive/c/windows/system32 and getting
a beautiful GNU colourised file listing.
- Oracle Knowledge Repository
- A wiki dedicated to Oracle Knowledge. Since this is a wiki, it might
not just be Oracle tomorrow. It might branch out into who knows what.