Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Multi-field Key definition using parent and child fields?

From: Barclay Alan K Contr AEDC/DYN <Alan.Barclay@------.--.--->
To: "'xmlschema-dev@--.---'" <-------------@--.--->
Date: 11/2/2004 11:00:00 PM
I have a schema that has a many2many relationship as follows:
 
 
Root----X----Y
      |
      |-A----B
 
 
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"/>
  </xs:key>
 
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:keyref>
     <xs:unique name="NoDups">
      <xs:selector xpath="B"/>
      <xs:field xpath="BFK1"/>
      <xs:field xpath="BFK2"/>
     </xs:unique>

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?
 
E.g. 
<Root>
  <X>
     <XID>1</XID>
     <Y>
        <YID>1</YID>
     </Y>
     <Y>
        <YID>2</YID>
     </Y>
  </X>
  <X>
     <XID>2</XID>
     <Y>
        <YID>1</YID>
     </Y>
     <Y>
        <YID>3</YID>
     </Y>
  </X>
  <A>
     <B>
        <BFK1>1</BFK1>
        <BFK2>1</BFK2>
        <Value>V1</Value>
     </B>
     <B>
        <BFK1>2</BFK1>
        <BFK2>2</BFK2>      <==== Would Fail to validate here.
        <Value>V2</Value>
     </B>
  </A>
</Root>
 
Thanks,
-Alan


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent