Lists Home |
Date Index |
- To: "Robert Koberg" <firstname.lastname@example.org>,"xml-dev" <email@example.com>
- Subject: RE: [xml-dev] hierarchical XML in a relational DB structure - moving nodes
- From: "Bullard, Claude L \(Len\)" <firstname.lastname@example.org>
- Date: Wed, 24 May 2006 16:04:19 -0500
- Thread-index: AcZ/a4x0Ju0etKSURkueYcH5+vLr4wACE/BA
- Thread-topic: [xml-dev] hierarchical XML in a relational DB structure - moving nodes
You are close to reinventing tumblers.
I built a system like this some years ago in Visual Basic. It is long
gone, but I recall that walking in was easy and walking out wasn't. If
you delete a branch, reordering was nasty. There was some ugly string
and substring handling. I also found it useful to keep the namespace
names and GIs in the table in case I wanted to search on GI values
because I was keeping multiple documents in the tables and generating
multiple document types from the information. After awhile it becomes
clear that it is better to use tables as tables and not to store trees
as piece parts (ok as blobs or varchars). It comes down to the why of
building it but it is fairly easy to build a tree on output from a table
but not so nice to store it in a table.
In the SGML days, there was a relational guru whose name I can't recall.
He was a strong advocate of relational document storage and published
some examples in ye Olde SGML TAG mag. After a while, the approach
began to break down possibly because this was in the days before
namespaces. Charles Goldfarb also published some papers on why this
approach has deficiencies.
From: Robert Koberg [mailto:email@example.com]
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:
To a relational database that might have a table representing it like:
First question: Is using an index position the best way to maintain the
position? (or is preceding and/or following sibling better? or something
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/node[@id=121] to the position
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)
The xml-dev list is sponsored by XML.org <http://www.xml.org>, an
initiative of OASIS <http://www.oasis-open.org>
The list archives are at http://lists.xml.org/archives/xml-dev/
To subscribe or unsubscribe from this list use the subscription