in reply to representing database schema in XML

If you'll search on XML and SQL, you'll eventually turn up a very interesting paper that demonstrates how to use left joins to turn relational data into hierarchical data--if you find the URL, drop me a note.

Sorry I can't be more specific--but it's a very good paper, and worth the search.

  • Comment on Re: representing database schema in XML

Replies are listed 'Best First'.
Re: Re: representing database schema in XML
by clemburg (Curate) on Jan 05, 2001 at 14:24 UTC

    Are you talking about this paper? It was one Google search away - see for yourself.

    Christian Lemburg
    Brainbench MVP for Perl
    http://www.brainbench.com

Re: Re: representing database schema in XML
by gildir (Pilgrim) on Jan 05, 2001 at 19:09 UTC
    It sees to me, that 'dirty' meant just the other side of SQL <-> XML mapping. I have similar problem with perl objects persistence in RDBMS.

    I need an XML docuent, that is able to describe DB scema. It should describe tables that will be used, their columns, data types, and some aditional information, as a perl regexpt used for validation of input into that table. Kinf of 'consistency' rules.

    If there is some XML DTD for such type of information, I rather used this stadard sulution that my proprietary one.

      Exactly!

      It just seems like a logical abstraction that i find it hard to believe that someone hasn't done it before. either that, or i am missing something.

      I mean, it seems facile to come up with a very basic DTD which only specified column names and a series of regexps which that column data must match in order to be accepted.

      Of course, this only allows 'intra' data checking; there is still the 'inter'-data checking - looking up external databases to see if X has been entered before etc etc...

      either way, being able to specify column data semantics in an external file certainly has it's virtues -- it would be such a simple thing to wrap this in an object:

      package SyntaxChecker; our $Column_Definitions = {}; BEGIN { load_definitions(); } sub new { my $proto = shift; my $column_name = shift || die; my $class = ref $proto || $proto; my $this = { column_name => $column_name, column_definition => $class->_get_definition( $column_name ), regexp => [ $class->_get_regexps( $column_name) ], regexp_cache => [], }; return $this; } sub get_cached_regexps { my $this = shift; return @{ $this->{'regexp_cache'} }; } sub validate { my $this = shift; my $input_data = shift || die; my $matched; if ( my @regexps = $this->_get_cached_regexps() ) { foreach my $regexp_sub ( @regexps ) { $regexp_sub->( $input_data ) || die $this->{'column_definition'}; $matched++; } } else { foreach my $regexp ( @{$this->{'regexp'}} ) { my $code = eval "sub{ $input_data =~ $regexp }"; push @{ $this->{'regexp_cache'} }, $code; } return $this->validate( $input_data ); } return $matched; }

      ok, so it's not a complete module -- no error checks or accessors or xml loading/parsing, but that took me all of 20 minutes, so a complete version wouldn't be much extra...

      just need a good DTD for the xml description... any takers???

      d_i_r_t_y