W3C home > Mailing lists > Public > xmlschema-dev@w3.org > November 2004

Multi-field Key definition using parent and child fields?

From: Barclay Alan K Contr AEDC/DYN <Alan.Barclay@arnold.af.mil>
Date: Tue, 2 Nov 2004 23:00:20 -0000
Message-ID: <200411022300.iA2N0h7x009925@andes.arnold.af.mil>
To: "'xmlschema-dev@w3.org'" <xmlschema-dev@w3.org>
I have a schema that has a many2many relationship as follows:
Where all are 1..N and B has a multiple field foreign key-type relationship
whose keys are X and Y.
(In reality, B also has another foreign key relationship with A, but it is
express compositionally rather than with key/keyref - i.e. by the
parent-child relationship.)
In an RDBMS, the B table would Look like (BPK,AFK,XFK,YFK) where the last
two fields (XFK,YFK) would be a single multi-field foreign key.
I have been able to solve this if I replicate the XPK value in the Y Node
(i.e. Y-Node has XPK and YPK elements where the XPK is simply a copy of the
parent value). 
Basically, I have a Key at Root similar to:
  <xs:key name="XYKEY">
   <xs:selector xpath="./X/Y"/>
   <xs:field xpath="XID"/>
   <xs:field xpath="YID"/>
and a 2-field unique and 2-field keyref at A:
     <xs:keyref name="XYKEYREF" refer="XYKEY">
      <xs:selector xpath="./B"/>
      <xs:field xpath="BFK1"/>
      <xs:field xpath="BFK2"/>
     <xs:unique name="NoDups">
      <xs:selector xpath="B"/>
      <xs:field xpath="BFK1"/>
      <xs:field xpath="BFK2"/>

This works and validates just like I want, however I have to duplicate the
X-value in the Y node.
Is there any way to specify a multi-field Key whose uniqueness is on the
combined values in the parent and child?
        <BFK2>2</BFK2>      <==== Would Fail to validate here.
Received on Tuesday, 2 November 2004 23:02:45 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:56:06 UTC