RE: SQL to XQuery translation

SQL provides explicit existential quantification. A predicate can
obviously be mapped into that. Or a subquery... 

Your SQL->XQuery example below is obviously correct at the level of
mapping the select iterator into the FLWR iterator. The problem comes
with:

Order: You need to wrap the FLWR into an unorder()
Predicate: Map non-existential semantics into existential semantics

But the main problem is on the data model level: How do you map Arr2 to
Arr2' in a way that you can map Arr1 into Arr1' and still have a good
query language against something that is not really relational from its
data model point of view.

If you can map your XQuery data model into a relational model that you
then can query using SQL, and your mapping allows you to map SQL back
into XQuery, you can obviously do it. Should you? It may be an
interesting academic exercise, but I don't see much value in it
personally (it is basically OLEDB over non-relational sources,
datajoiner over non-relational sources): Neither of which are really
successful.

Best regards
Michael

> -----Original Message-----
> From: Murali Mani [mailto:mani@CS.UCLA.EDU]
> Sent: Thursday, January 15, 2004 12:26 PM
> To: Michael Rys
> Cc: David Song; www-ql@w3.org
> Subject: RE: SQL to XQuery translation
> 
> 
> Michael,
> 
> Some questions regarding Query Language translations propped up
recently.
> This was one that we could not answer..
> 
> When you do XQuery -> SQL, how do you translate predicates?
> 
> a predicate in XPath such as
> 
> path [predicate]/ ...
> 
> we need existential semantics over a potential result set.. does this
get
> translated to a subquery in SQL???
> 
> best, murali.
> 
> -------------------------
> 
> Note: for SQL -> XQuery might be easier (if we consider simple
queries)..
> 
> for example,
> SELECT <Arr1>
> FROM <Arr2>
> WHERE <Arr3>
> 
> can be translated to (the way we teach SQL semantics in DB I ..)
> 
> for <Arr2'>
> where <Arr3'>
> return <Arr1'>
> 
> i think it is not difficult to translate these Arr2 -> Arr2' etc..??
Are
> there things that I am overlooking??
> 
> On Thu, 15 Jan 2004, Michael Rys wrote:
> 
> > Some reasons why there is not much done in this area:
> >
> > 1. SQL is not powerful enough alone to query true XML data where
mixed
> > content, order, changing structure really matters. You would have to
> > extend SQL fundamentally to allow this. There is some work going on
at
> > the relational database companies and the ANSI/ISO standards level.
> > However, the focus there is mainly to leverage XPath and XQuery in
the
> > context of SQL expressions. So mapping SQL to XQuery would also mean
> > that you define  relational semantics over the XML data, which you
> > cannot easily do for general XML documents (see the discussions of
> > edge/node-tables to represent XML relationally for some of the
> > complexity).
> >
> > 2. In order to query relational data marked up in XML, most
commercial
> > systems provide a mapping level into XML (annotated schemata in SQL
> > Server 2000, XSD-based OR mapping in Oracle 9i, DADs in IBM DB2) and
> > then just let you use SQL to query it. So no need to map it to
XQuery
> > since the primary implementation architecture is SQL.
> >
> > If it would have been easy, I guess we would not have invested into
> > XQuery in the first place but just defined a relational semantics on
XML
> > and be done with it...
> >
> > Best regards
> > Michael
> >
> > > -----Original Message-----
> > > From: www-ql-request@w3.org [mailto:www-ql-request@w3.org] On
Behalf
> > Of
> > > David Song
> > > Sent: Wednesday, January 14, 2004 11:39 PM
> > > To: www-ql@w3.org
> > > Subject: SQL to XQuery translation
> > >
> > >
> > > I am in need of researching, designing, and
> > > implementing techniques to translate from SQL to
> > > XQuery.  Most (if not all) research has been focused
> > > on XQuery->SQL, now I need the reverse!  I believe is
> > > challenge is how to map SQL predicates into XPath
> > > expressions.  SQL joins is another challenge.
> > >
> > > The business usage case is that users need to be able
> > > to construct AdHoc queries using SQL to query XML data
> > > residing in native XML database.  I need help in
> > > designing algorithms to map SQL to XQuery/XPath.  I
> > > have not found any research in this area.
> > >
> > > I very much appreciate if anyone can point me in the
> > > right direction.  I have some preliminary design
> > > thoughts if anyone is interested in a more detailed
> > > discussion with me.  Thanks!
> > >
> > > David Song
> > > College of Engineering
> > > San Jose State University
> > >
> > > __________________________________
> > > Do you Yahoo!?
> > > Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
> > > http://hotjobs.sweepstakes.yahoo.com/signingbonus
> > >
> >
> >

Received on Thursday, 15 January 2004 15:37:48 UTC