in reply to Is there any script to translate a simple SQL script to an ER diagram?

For the sake of completeness, and in case you know how to solve the problem, this is the SQL code:

-- -- DocumentStore Database creation -- -- $Id$ CREATE TABLE PEOPLE ( id serial PRIMARY KEY, nick varchar(16) UNIQUE NOT NULL, passwd varchar(14) NOT NULL, name varchar(64), surname varchar(64) NOT NULL, email varchar(96) UNIQUE NOT NULL ) ; CREATE TABLE GROUPS ( id serial PRIMARY KEY, name varchar(32) UNIQUE NOT NULL, deflevel smallint DEFAULT 15 ) ; CREATE TABLE PG ( groupID integer REFERENCES GROUPS (id), userID integer REFERENCES PEOPLE (id), level smallint, CHECK (level BETWEEN 0 AND 32) ) ; CREATE TABLE TYPES ( id serial PRIMARY KEY, descr varchar(64) UNIQUE NOT NULL, mime varchar(96) DEFAULT 'application/octet-stream' NOT + NULL ) ; CREATE TABLE STATUSES ( id serial PRIMARY KEY, descr varchar(64) UNIQUE NOT NULL ) ; CREATE TABLE DOCUMENTS ( id serial PRIMARY KEY, title varchar(255) NOT NULL, type integer REFERENCES TYPES (id), published date NOT NULL, updated date NOT NULL, descr varchar(200), url varchar(128) UNIQUE NOT NULL, status integer REFERENCES STATUSES (id) ) ; CREATE TABLE AUTHORS ( id serial PRIMARY KEY, name varchar(128) UNIQUE NOT NULL ) ; CREATE TABLE AD ( authorID integer REFERENCES AUTHORS (id), docID integer REFERENCES DOCUMENTS (id) ) ; CREATE TABLE SECTIONS ( id serial PRIMARY KEY, descr varchar(64) UNIQUE NOT NULL ) ; CREATE TABLE SD ( sectionID integer REFERENCES SECTIONS (id), docID integer REFERENCES DOCUMENTS (id) ) ; CREATE TABLE ACCESS_LIST ( groupID integer REFERENCES GROUPS (id), level smallint, docID integer REFERENCES DOCUMENTS (id), CHECK (level BETWEEN 0 AND 32) ) ;

It seems to me that SQL::Translator loses its head with the foreign keys.

Anyway, if you know another perl tool that does the job, I'll be happy to try it

Ciao!
--bronto


The very nature of Perl to be like natural language--inconsistant and full of dwim and special cases--makes it impossible to know it all without simply memorizing the documentation (which is not complete or totally correct anyway).
--John M. Dlugosz
  • Comment on Re: Is there any script to translate a simple SQL script to an ER diagram?
  • Download Code

Replies are listed 'Best First'.
•Re: Re: Is there any script to translate a simple SQL script to an ER diagram?
by merlyn (Sage) on Aug 20, 2003 at 17:32 UTC
Re: Re: Is there any script to translate a simple SQL script to an ER diagram?
by perrin (Chancellor) on Aug 20, 2003 at 18:25 UTC
    SQL::Translator has worked very well for me. Use the latest from CVS at http://sqlfairy.sourceforge.net/, not the version on CPAN. Support on the mailing list is quite good as well. It handled foreign keys just fine with a MySQL schema I fed it.
Re: Re: Is there any script to translate a simple SQL script to an ER diagram?
by PodMaster (Abbot) on Aug 21, 2003 at 07:01 UTC
    You need bleeedin edge man ;) sql.bronto.t_GraphViz.png

    And just for kicks, this is your psql converted into psql by the sql fairy

    update: That would seem to suggest that the CHECK constraint(?) is somehow mishandled. You should submit a bug report (http://sf.net/projects/sqlfairy ;)

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.

      Much much better than my previous results, PodMaster, thanks. But... two tables are missing: PG and ACCESS_LIST...

      --bronto


      The very nature of Perl to be like natural language--inconsistant and full of dwim and special cases--makes it impossible to know it all without simply memorizing the documentation (which is not complete or totally correct anyway).
      --John M. Dlugosz
Re: Re: Is there any script to translate a simple SQL script to an ER diagram?
by menolly (Hermit) on Aug 20, 2003 at 17:15 UTC
    What flags, if any, are you using with sqlt_diagram.pl?

      Here you are:

      sqlt-diagram.pl --output grafico.png --db=PostgreSQL createdb.sql

      Same flags for sqlt-graph.pl

      Ciao!
      --bronto


      The very nature of Perl to be like natural language--inconsistant and full of dwim and special cases--makes it impossible to know it all without simply memorizing the documentation (which is not complete or totally correct anyway).
      --John M. Dlugosz