Simplified/shorthand SQL Data Definition Languages? Simplified/shorthand SQL Data Definition Languages? sql sql

Simplified/shorthand SQL Data Definition Languages?


Actually, I just finished creating a php script, which does exactly this, but I hope there is something more professional out there...

Demo of my converter:

http://simpleddl.orgfree.com

Example input:

= ID id P AIperson  ID  mother_id -> person  father_id -> person  !FK mother_id, father_id -> family U:C, D:Cfamily  P female_id -> person  P male_id   -> person

Output:

CREATE TABLE IF NOT EXISTS person (   id         INT NOT NULL AUTO_INCREMENT,   mother_id  INT NOT NULL,   father_id  INT NOT NULL,   PRIMARY KEY ( id )) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;CREATE TABLE IF NOT EXISTS family (   female_id  INT NOT NULL,   male_id    INT NOT NULL,   PRIMARY KEY ( female_id, male_id )) ENGINE=InnoDB DEFAULT CHARSET=utf8;ALTER TABLE person ADD FOREIGN KEY ( mother_id ) REFERENCES person( id );ALTER TABLE person ADD FOREIGN KEY ( father_id ) REFERENCES person( id );ALTER TABLE person ADD FOREIGN KEY ( mother_id, father_id ) REFERENCES family( female_id, male_id ) ON DELETE CASCADE ON UPDATE CASCADE;ALTER TABLE family ADD FOREIGN KEY ( female_id ) REFERENCES person( id );ALTER TABLE family ADD FOREIGN KEY ( male_id ) REFERENCES person( id );


I see you mentioned the text-to-ddl tool that is available on http://sqlfiddle.com. This is actually a tool I built (sqlfiddle.com is my site) in JavaScript specifically to try to make it easier to take the text tables people post in their StackOverflow questions and more quickly translate them into real DDL. I think it works fairly well for a fair amount of common variation of text table formats, but I'm sure it could use some work to handle a greater variety. I support the different DDL types via separate handlebars.js templates for each one (MS SQL, Oracle, PostgreSQL, MySQL and SQLite).

The whole library is written as JavaScript, so if anyone would like to help me make it better, I would love your contributions. Fork me on github and look for the file javascripts/ddl_builder.js. I would love to have some pull requests!