RE: XQuery and relational databases...

> It has been asserted that the relational grouping operator 
> (GROUP BY) is 
> not appropriate for use in an XML query language.  I admit 
> that I don't 
> fully understand the arguments (yet), but I have a sort of intuitive 
> understanding of at least some of the issues.  The most 
> important one is, 
> of course, that the relational GROUP BY operates strictly on 
> a virtual 
> table (a regular, rectangular structure with every cell occupied by 
> *something*, even if the null value), while an XQuery 
> grouping operator 
> would have to operate on semi-structured tree structures.  
> The challenges 
> of the latter clear exceed those of the former, even if some 
> lessons of the 
> former can be learned and used in designing the latter.

I think the real difference is not in the nature of the input, it is in the
nature of the output. If you look at the use cases compiled by Steve Muench
(I posted a reference earlier), they all have the characteristic that the
output is a tree, in the form

<output>
   ...
   <group>
       group header
       <item>
       ....
       </item> (repeats once for each item in a group)
       group footer
   </group> (repeats once for each group)
   ....
</output>

This is quite different from SQL grouping, which is constrained to produce a
table.

> But I think that it 
> really is too late in the process to add such an operator now.
> 
I fear that you are probably right, given that most XQuery working group
members are not up to speed with the extensive experience of XML grouping
problems and solutions developed in the XSLT user community, and are likely
to want to investigate the problem from scratch rather than re-using
existing solutions.

Michael Kay

Received on Saturday, 8 March 2003 09:46:27 UTC