[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

hierarchical XML in a relational DB structure - moving nodes

  • To: xml-dev <xml-dev@l...>
  • Subject: hierarchical XML in a relational DB structure - moving nodes
  • From: Robert Koberg <rob@k...>
  • Date: Wed, 24 May 2006 15:53:08 -0400
  • User-agent: Thunderbird 1.5.0.2 (Windows/20060308)

xml move node
Hi,

I want to use a relational database to store data that is nested and 
where the order is preserved. I am having a hard time wrapping my head 
around how to do the following mostly because I don't have much 
experience with relational databases.

I am looking at mapping a structure like so:

<node id="1">
   <node id="11">
     <node id="111">
       <node id="1111"/>
       <node id="1112"/>
       <node id="1113"/>
     </node>
     <node id="112"/>
     <node id="113"/>
     <node id="114"/>
   </node>
   <node id="12">
     <node id="121"/>
     <node id="122"/>
     <node id="123"/>
   </node>
</node>

To a relational database that might have a table representing it like:

Node
-------
id
parentId
parentIndexPosition

First question: Is using an index position the best way to maintain the 
position? (or is preceding and/or following sibling better? or something 
else?)

OK, lets say I have imported some data/XML into the above table, giving 
appropriate parents and index positions.

Next, say I want to move /node/node[2]/node[@id=121] to the position 
/node/node[1]/node[1].

How do you handle updating the index position of other nodes? All 
children of /node/node[@id=12] will need their parentIndexPosition moved 
down one. And all children of /node/node[@id=11] will need their 
parentIndexPosition moved up one. (the ID attributes where abritrarily 
created and should not indicate position)

Is there a built in mechanism to do this type of thing in relational 
databases? If not how would an UPDATE look?

Are there any java libraries or articles out there that handle this type 
of thing? (I am having a hard time finding anything with google)

thanks,
-Rob


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.