Loading ...
Sorry, an error occurred while loading the content.

Re: [xml-dbms] Re: 1 to more Relations over more generations - error or missunderstanding

Expand Messages
  • Ronald Bourret
    This is a very subtle error and was not easy to find :) The problem is that , not should (eventually) be a related class of . Thus, the inline maps
    Message 1 of 5 , Jul 31, 2004
    • 0 Attachment
      This is a very subtle error and was not easy to find :)

      The problem is that <d>, not <a> should (eventually) be a related class
      of <z>. Thus, the inline maps should occur in the class map for z and d
      should be mapped using a related class / class map. In other words, your
      map should be:

      <Maps>
      <ClassMap>
      <ElementType Name="z"/>
      <ToClassTable Database="test" Name="Z"/>
      <PropertyMap>
      <ElementType Name="z1/>
      <ToColumn Name="z"/>
      </PropertyMap>
      <InlineMap>
      <ElementType Name="a"/>
      <InlineMap>
      <ElementType Name="b"/>
      <InlineMap>
      <ElementType Name="c"/>
      <RelatedClass KeyInParentTable="Unique">
      <ElementType Name="d"/>
      <UseUniqueKey Name="PrimaryKey"/>
      <UseForeignKey Name="z_d"/>
      </RelatedClass>
      </InlineMap>
      </InlineMap>
      </InlineMap>
      </ClassMap>
      <ClassMap>
      <ElementType Name="d"/>
      <ToClassTable Database="test" Name="d"/>
      <PropertyMap>
      <PCDATA />
      <ToColumn Name="d"/>
      </PropertyMap>
      </ClassMap>
      </Maps>

      Note that I used the <PCDATA> element to map the content of <d> to
      column d. This is because <d> is a simple element type (it can only
      contain text). In your case, I assume that <d> is more complex and will
      need to be mapped using PropertyMaps with ElementType elements.

      As I described in my last message, this map will work when transferring
      data from XML to the database, but will not correctly transfer data from
      the database to XML if there are more than one a or b elements inside a
      z element.

      For example, if you transfer data from:

      <z>
      _<z1></z1>
      _<a>*
      __<b>*
      ___<c>
      ____<d></d>

      to the database and then transfer it back to XML, you will get a
      document with the following structure, in which there is only one a, one
      b, one c, and multiple d's:

      <z>
      _<z1></z1>
      _<a>
      __<b>
      ___<c>
      ____<d></d>*

      For a description of the technical reasons for this, see:

      http://www.rpbourret.com/xmldbms/PassThrough.txt

      This is written using version 1.x (not version 2.0) terminology and uses
      the term "pass-through" instead of "inline", but still explains why
      reconstructing the document is technically impossible given what is
      stored in the database.

      -- Ron

      drreblaus@... wrote:
      >
      > well i think there is a missunterstanding and probably an error form
      > myside:
      > i have two tables:
      > table z (z pk)
      > table d (d pk, z fk)
      >
      > i just want a 1:n-Relationship from z/z1 to d and the xml matches this
      > schema-structure:
      > <z>
      > <z1></z1>
      > _<a>*
      > __<b>*
      > ___<c>
      > ____<d></d>
      >
      > i did not find any solution to map this structure to the relationship
      > above.
      > i made this map but i just the cardinality from <a> as the number of
      > datasets for table d which is obviously wrong. with inlinemap i can
      > just follow one sucessor and i have not any table for a further
      > classmap.
      >
      > <Maps>
      > <ClassMap>
      > <ElementType Name="a"/>
      > <ToClassTable Database="test" Name="d"/>
      > <InlineMap>
      > <ElementType Name="b"/>
      > <InlineMap>
      > <ElementType Name="c"/>
      > <PropertyMap>
      > <ElementType Name="d"/>
      > <ToColumn Name="d"/>
      > </PropertyMap>
      > </InlineMap>
      > </InlineMap>
      > </ClassMap>
      > <ClassMap>
      > <ElementType Name="z"/>
      > <ToClassTable Database="test" Name="Z"/>
      > <PropertyMap>
      > <ElementType Name="z0"/>
      > <ToColumn Name="z"/>
      > </PropertyMap>
      > <RelatedClass KeyInParentTable="Unique">
      > <ElementType Name="a"/>
      > <UseUniqueKey Name="PrimaryKey"/>
      > <UseForeignKey Name="z_d"/>
      > </RelatedClass>
      > </ClassMap>
      > </Maps>
    Your message has been successfully submitted and would be delivered to recipients shortly.