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

You need bleeedin edge man ;) sql.bronto.t_GraphViz.png

Description of Schema

Tables

PEOPLE
GROUPS
TYPES
STATUSES
DOCUMENTS
AUTHORS
AD
SECTIONS
SD

PEOPLE

Top
Field Name Data Type Size Default Other Foreign Key
id integer 11
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

GROUPS

Top
Field Name Data Type Size Default Other Foreign Key
id integer 11
name varchar 32 UNIQUE, NOT NULL
deflevel integer 5 15

TYPES

Top
Field Name Data Type Size Default Other Foreign Key
id integer 11
descr varchar 64 UNIQUE, NOT NULL
mime varchar 96 application/octet-stream NOT NULL

STATUSES

Top
Field Name Data Type Size Default Other Foreign Key
id integer 11
descr varchar 64 UNIQUE, NOT NULL

DOCUMENTS

Top
Field Name Data Type Size Default Other Foreign Key
id integer 11
title varchar 255 NOT NULL
type integer 10 TYPES.id
published date 0 NOT NULL
updated date 0 NOT NULL
descr varchar 200
url varchar 128 UNIQUE, NOT NULL
status integer 10 STATUSES.id

AUTHORS

Top
Field Name Data Type Size Default Other Foreign Key
id integer 11
name varchar 128 UNIQUE, NOT NULL

AD

Top
Field Name Data Type Size Default Other Foreign Key
authorID integer 10 AUTHORS.id
docID integer 10 DOCUMENTS.id

SECTIONS

Top
Field Name Data Type Size Default Other Foreign Key
id integer 11
descr varchar 64 UNIQUE, NOT NULL

SD

Top
Field Name Data Type Size Default Other Foreign Key
sectionID integer 10 SECTIONS.id
docID integer 10 DOCUMENTS.id

Created by SQL::Translator

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

DROP TABLE "PEOPLE"; CREATE TABLE "PEOPLE" ( "id" serial, "nick" character varying(16) NOT NULL, "passwd" character varying(14) NOT NULL, "name" character varying(64), "surname" character varying(64) NOT NULL, "email" character varying(96) NOT NULL, CONSTRAINT pk_PEOPLE PRIMARY KEY ("id"), CONSTRAINT 1_PEOPLE UNIQUE ("nick"), CONSTRAINT 2_PEOPLE UNIQUE ("email") ); DROP TABLE "GROUPS"; CREATE TABLE "GROUPS" ( "id" serial, "name" character varying(32) NOT NULL, "deflevel" integer DEFAULT '15', CONSTRAINT pk_GROUPS PRIMARY KEY ("id"), CONSTRAINT 1_GROUPS UNIQUE ("name") ); DROP TABLE "TYPES"; CREATE TABLE "TYPES" ( "id" serial, "descr" character varying(64) NOT NULL, "mime" character varying(96) DEFAULT 'application/octet-stream' NOT +NULL, CONSTRAINT pk_TYPES PRIMARY KEY ("id"), CONSTRAINT 1_TYPES UNIQUE ("descr") ); DROP TABLE "STATUSES"; CREATE TABLE "STATUSES" ( "id" serial, "descr" character varying(64) NOT NULL, CONSTRAINT pk_STATUSES PRIMARY KEY ("id"), CONSTRAINT 1_STATUSES UNIQUE ("descr") ); DROP TABLE "DOCUMENTS"; CREATE TABLE "DOCUMENTS" ( "id" serial, "title" character varying(255) NOT NULL, "type" integer, "published" date NOT NULL, "updated" date NOT NULL, "descr" character varying(200), "url" character varying(128) NOT NULL, "status" integer, CONSTRAINT pk_DOCUMENTS PRIMARY KEY ("id"), FOREIGN KEY ("type") REFERENCES TYPES ("id"), CONSTRAINT 1_DOCUMENTS UNIQUE ("url"), FOREIGN KEY ("status") REFERENCES STATUSES ("id") ); DROP TABLE "AUTHORS"; CREATE TABLE "AUTHORS" ( "id" serial, "name" character varying(128) NOT NULL, CONSTRAINT pk_AUTHORS PRIMARY KEY ("id"), CONSTRAINT 1_AUTHORS UNIQUE ("name") ); DROP TABLE "AD"; CREATE TABLE "AD" ( "authorID" integer, "docID" integer, FOREIGN KEY ("authorID") REFERENCES AUTHORS ("id"), FOREIGN KEY ("docID") REFERENCES DOCUMENTS ("id") ); DROP TABLE "SECTIONS"; CREATE TABLE "SECTIONS" ( "id" serial, "descr" character varying(64) NOT NULL, CONSTRAINT pk_SECTIONS PRIMARY KEY ("id"), CONSTRAINT 1_SECTIONS UNIQUE ("descr") ); DROP TABLE "SD"; CREATE TABLE "SD" ( "sectionID" integer, "docID" integer, FOREIGN KEY ("sectionID") REFERENCES SECTIONS ("id"), FOREIGN KEY ("docID") REFERENCES DOCUMENTS ("id") );
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.

Replies are listed 'Best First'.
Re: Re: Re: Is there any script to translate a simple SQL script to an ER diagram?
by bronto (Priest) on Aug 21, 2003 at 07:36 UTC

    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