My current project is a database for work. To save myself future headaches, I've been sticking to the code it once principle. Specifically, I've been coding table and class information in YAML, then defining templates (using the Template Toolkit, of course) to produce SQL code, Perl modules, and (ta da!) a Makefile.
With lots of Perl glue.
And now I've got the biggest headache of them all.
Moral: trying to save myself headaches later is pointless if my brain explodes in the process!
Update: Happily, the headache is quickly fading. I added a target in my makefile spec to produce a (longish) SQL command file that populates the database in one transaction, and the resulting file is looking good. It's not running to completion, because my data has a few hiccups in it that my data preparation scripts didn't catch, but that's easy enough to fix.
Moral #2: When trying to save yourself headaches later, don't try to save them all at once. One aspirin at a time, my friend!
Stick it out... (Score:1)
If it is a mess, at least you'll have learned a lot about just how far to go with this kind of thing.
Sure, your brain may hurt now, but no pain, no gain. On the other hand, you have failed to save yourself headaches...
Look at it this way, if it is a failure, and your brain does explode, at least it will be a spectacular failure. I'd rather be a spectacular failure than a boring success!
(when did I start sounding like Stuart Smalley?)
Re:Stick it out... (Score:1)
Thanks for the encouraging words. My brain is much better now. Lying in the grass with my eyes closed helped a lot.
:-)I wouldn't say it's a mess, just big and I tend to work on several parts of it at once. When I'm in the groove this can work very well (until my brain conks out); at other times, it results in a certain amount of wheel-spinning...
CREATE TABLE abstraction? (Score:1)
Does this allow you to describe a table structure and dump out SQL statements to create it in various databases? That'd surely be useful!
Re:CREATE TABLE abstraction? (Score:3, Funny)
Re:CREATE TABLE abstraction? (Score:1)
Now that you mention it, Alzabo::Create::Schema [cpan.org] looks extremely useful. Darn you for making my life easier yet again!
Re:CREATE TABLE abstraction? (Score:1)
Maybe. I'm only targeting PosgretSQL at the moment, but it should be easy to target other RDBMSes too, as this would mostly* entail making a few new SQL templates.
* There are bound to be some PostgreSQLisms outside of the templates; hopefully, not many.
Here's a much-abridged example of a table definition:
tables/Orders/definition.yml
Re:CREATE TABLE abstraction? (Score:2)
And you can create it all from dia which is nice - should be easy to create your other stuff from dia too.
I am currently working on a new project to combine schema and code creation so that you can create your databases, your queries (all kept in a nice phrasebook natch), and documentation from a couple of perl scripts.
@JAPH = qw(Hacker Perl Another Just);
print reverse @JAPH;
Re:CREATE TABLE abstraction? (Score:1)