Re: Foreign Keys in XML

From: Date: Wed, 25 Oct 2006 18:16:52 +0000
Subject: Re: Foreign Keys in XML
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-44749@lists.php.net to get a copy of this message
David Morse wrote:
Lukas -
    I just submitted a proposal for a PEAR class DB_Table_Database
that is a database layer built on top of DB_Table. It includes methods to read and write the database schema, including foreign keys, as XML. I've tried to follow the MDB2 schema (though I've used SimpleXML rather than the MDB2 parser), including your proposal for a syntax for foreign keys.
Which one exactly are you referring to? There have been multiple proposals. Anyways, the current parser should actually be replaced with a SimpleXML one. MDB2_Schema actually supports using different parser classes, so they could coexist.
    I wrote a comment, which I believe you've seen, which was critical of the proposed syntax, and suggested some alternatives.  My basic point was that I thought it was a bad idea to treat a foreign key reference as a kind of index, rather than a separate kind of element.  After looking around a bit, I think that the relevant RDBMSs treat references and indices as separate entities, even when they require
Well pretty much all RDBMS use an index for unique and primary key constraints. Only very few use an index for a foreign key constraint.
that a referencing or referenced key also have an index. It appears that ANSI SQL requires only that the referenced key have a unique constraint declared. MySQL with InnoDB does seem to require that both referencing and referenced key have unique indices declared, though I've not yet found any indication that this is true for other systems. There is a potential for annoying name clashes in the XML if one defines both separate index and foreign key reference on the same column or list of columns and gives them the same name, which is the natural thing to do.
Not sure I understand this one.
     What is the status of the proposed extension of the MDB2 XML syntax?  If we agreed on a somewhat different syntax for foreign keys
at this stage, would it be possible for you to adapt?
The status is that I am hoping someone will implement it :) However I have given lead of the MDB2_Schema package to Igor. regards, Lukas

« previous php.pear.dev (#44749) next »