OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   RE: XML database

[ Lists Home | Date Index | Thread Index ]
  • From: Joshua Allen <joshuaa@microsoft.com>
  • To: 'Huaxin Zhang' <hxzhang@cs.ualberta.ca>, Michael Rys <mrys@microsoft.com>
  • Date: Sun, 08 Oct 2000 14:34:59 -0700

This is somewhat like the problems of representing "ragged hierarchies" in a
dbms, for example an org chart.  Often people use a self-joining table for
relationships of this sort.  If you store the data relationally as data with
each record having a pointer to a "ParentID" in the same table, you can
select out very easily into and id/idref structure (see the sample XML
below) and use something like the below style sheet to transform it into a
tree.

If you normally only change (or move) one node at a time, this structure
makes sense.  You can change the granularity at which you select out the
nodes from the relational store (how deep) if you are going to do clever
things like caching and want maximum performance.  Also, there is nothing
mandating that this technique has to be used down to the individual node
level; you can use this only where it makes sense..

Also, for batch inputs, it is possible that you could build a stylesheet
which "flattens" a ragged hierarchy into an id/idref structure which could
then be easily sent in as an updategram (or however you want to put it in).
Such a stylesheet would not be hard; just a reverse of the one I included
here.  The only thing that gets tricky when you start talking about the
potential for updates to completely ragged hierarchies is that you are going
to have to figure out how you want to represent "diffs".  If your hierarchy
structure is completely indeterminate, it can be challenging to figure out
whether something represents a change, add, or whatever.  These kinds of
issues and others are why Michael recommended looking at some of the
research.  I also recommend looking for "Suciu".


-J


<!-- THE STYLESHEET -->
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
 <xsl:output method="xml" indent="yes" />

 <xsl:template match="/*[position()=1]">
  <xsl:call-template name="children" />
 </xsl:template>

 <xsl:template name="children">
  <xsl:param name="parent" select="0" />
  <xsl:param name="indent" select="0" />
   <xsl:for-each select="/*[position()=1]/node()[@idref=$parent]" >
      <level>
      <xsl:attribute name="name"><xsl:value-of
select="@name"/></xsl:attribute>
      <xsl:attribute name="indent">
         <xsl:value-of select="$indent" />
      </xsl:attribute>
      <xsl:attribute name="type">
        <xsl:value-of select="name(.)" />
      </xsl:attribute>
      <xsl:call-template name="children">
        <xsl:with-param name="parent"><xsl:value-of
select="@id"/></xsl:with-param>
        <xsl:with-param name="indent"><xsl:value-of select="$indent +
1"/></xsl:with-param>
      </xsl:call-template>
      </level>
   </xsl:for-each>
  </xsl:template>
</xsl:stylesheet>


<!-- THE XML -->
<?xml version="1.0"?>
<tree>
  <comment id="10" idref="8" name="a barrista makes coffee" />
  <item id="1" idref="0" name="Dictionary" />
  <item id="2" idref="1" name="A" />
  <item id="3" idref="2" name="abba" />
  <item id="4" idref="2" name="ala" />
  <item id="5" idref="1" name="B" />
  <item id="6" idref="1" name="C" />
  <item id="7" idref="2" name="anemone" />
  <item id="8" idref="5" name="Barrista" />
  <comment id="9" idref="3" name="abba is a band" />
</tree>

> -----Original Message-----
> From: Huaxin Zhang [mailto:hxzhang@cs.ualberta.ca]
> Sent: Sunday, October 08, 2000 1:48 PM
> To: Michael Rys
> Cc: xml-dev@lists.xml.org
> Subject: RE: XML database
> 
> 
> Hi, Michael
> 
> I have read almost all those things you just mentioned. However,
> it is extremely difficult to save a serie of XML files of one DTD into
> relational database. Suppose the DTD is like having a tree 
> like object,
> the branch factor of EVERY level is UNKNOWN. Each XML file is 
> like this
> tree structure and all of them are to be saved into database. 
> Query of any
> of branch of any of the XML trees should be done in real time. 
> I see through almost any kind of the database claiming for 
> XML support,
> however, I still can't find a demo dealing with the problem of mine. 
> 
> 
> On Sun, 8 Oct 2000, Michael Rys wrote:
> 
> > There are several ways on how to map XML into relational 
> storage structures.
> > There were some research papers published on this (e.g., by Kossman,
> > Florescu and others). Also look at SQLServer 2000's edgetable format
> > generated by the OpenXML rowset provider as an extreme form 
> on one side of
> > the spectrum to represent arbitrary XML documents in relations.
> > 
> > It all depends on what you want to do with the data and how 
> much schema
> > information you have available...
> > 
> > Best regards
> > Michael
> > 
> > > -----Original Message-----
> > > From: Huaxin Zhang [mailto:hxzhang@cs.ualberta.ca]
> > > Sent: Sunday, October 08, 2000 12:36 PM
> > > Cc: 'xml-dev@lists.xml.org'
> > > Subject: XML database
> > > 
> > > 
> > > Perhaps this is an old question, but I still can't find 
> > > answer anywhere:
> > > 
> > > Suppose I have a hierarchy DOM structure, each node may have 
> > > undefinite 
> > > number of child nodes. How to save this may-be extremely 
> large tree
> > > structured XML files into some kind of database rather than a 
> > > large chunk
> > > in memory or flat file has been a problem for me for a long time.
> > > 
> > > Would anybody help with me with this? I would prefer 
> > > Relational DB, but
> > > seems I have to shift to OO-DB, which I know absolutely 
> nothing about.
> > > 
> > > 
> > > 
> > > 
> > 
> 




 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS