Techmania

June 9, 2008

Creating ER diagrams from SQL

Filed under: Uncategorized — mifan @ 10:34 am

SQLt/SQL::Translator/SQLFairy is a great tool to create ER diagrams from SQL:

SQL::Translator is a group of Perl modules that manipulate structured data definitions (mostly database schemas) in interesting ways, such as converting among different dialects of CREATE syntax (e.g., MySQL-to-Oracle), visualizations of schemas (pseudo-ER diagrams: GraphViz or GD), automatic code generation (using Class::DBI), converting non-RDBMS files to SQL schemas (xSV text files, Excel spreadsheets), serializing parsed schemas (via Storable, YAML and XML), creating documentation (HTML and POD), and more.

In Ubuntu Linux and Debian Linux, this can be obtained by installing SQLFairy:
apt-get install sqlfairy
This is quite useful if you follow a bottom-up approach: create the SQL first, and then create ER diagrams – although this might not be a common development method, it does have its uses, and some of us like it :)
So for instance, say you have a MySQL schema named sample.sql. To create a ER diagram with color, named sample_schema.png, run the following in the command line:
sqlt-diagram -d=MySQL -o=sample_schema.png sample.sql --color
where -d=MySQL specified the MySQL driver. Other available drivers can be obtained by:
sqlt -l
Additionally, sqlt can also be used to convert between various database schemas as well.

SQLFairy ER Diagram

8 Comments »

  1. [...] while searching for another application to do just what I want (and not cost me a cent) I found a post about something that will be extremely [...]

    Pingback by ER Diagrams from SQL files | Christian Biggins — November 21, 2008 @ 2:03 am | Reply

  2. any news coming ?

    Comment by twefiace — May 23, 2009 @ 4:22 am | Reply

  3. good one…… btw, any utility to generate sql script from a e-r diagram (like visio in win32) ?

    Comment by chatura — June 16, 2009 @ 9:24 am | Reply

  4. Works great, as long as you don’t have more than five tables in your database. Anything bigger than that and you get a big mess of lines that go all over the place. Biggest drawback is lack of crow’s feet notation which for me is a must with such diagrams

    Comment by zagor — August 25, 2009 @ 3:19 am | Reply

  5. its very good

    Comment by al3boshi — October 6, 2009 @ 9:28 am | Reply

  6. It really very good,

    Thanks for the tool.

    Comment by somanath — February 22, 2010 @ 9:19 am | Reply

  7. Thanks a lot,you really saved me.

    Comment by Shafaet Ashraf — January 10, 2012 @ 11:07 pm | Reply

  8. good tools

    Comment by saleh alkhaier — April 15, 2012 @ 1:28 pm | Reply


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Theme: Rubric. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.