This is indeed a very good idea.

A couple of years ago, I proposed a database abstraction layer called DBO to do this kind of thing. You specify the structure as a schema and then create visitors which walk the schema and perform various operations such as queries, validations, views, etc.

A colleague of mine at the time produced a working demo which you can find in my CPAN directory (id: abw) but it is known to be flaky and more of an experiment than a working product. By all means have a look, but don't expect too much from it :-)

The biggest problem was the lack of a standard way to represent the schema. The recent W3C XML Schema specification addresses this issues and provides a flexible and standards based way to do just this. I've started work on an XML::Schema module which will grok XML schemas and should allow you to build all sorts of cool schema based applications on top of it. Things like automatically generating database abstraction layers, SQL <-> object marshalling code, display/edit forms, validation and so on.

Watch this space, but bear in mind that XML Schema is non trivial, so don't hold your breath waiting for anything too soon.


In reply to Re: representing database schema in XML by abw
in thread representing database schema in XML by d_i_r_t_y

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.