Re: define views using xquery

MessageI think SQL is obviously more powerful than XQuery, although it cannot replace XQuery because SQL is for relational database and XQuery is for hierarchical database.

the SQL I give does construct the output I want. the schema I gave ( spj(jno, sno, pno, price) ) is based on the FD: jno, sno, pno ---> price, which is in 3NF.

in this case, the SQL is never rigged and the comparison is fair.

anyway, thank you for your comments.

  ----- Original Message ----- 
  From: TAN Kuan Hui 
  To: Chen Ya Bing 
  Cc: www-ql@w3.org 
  Sent: Monday, February 25, 2002 4:53 PM
  Subject: Re: define views using xquery


  Firstly, you have to be realistic that XQuery is still in draft stage. 
  Selectively evaluate XQuery is not objective evaluation.

  Your SQL did not construct the output, strictly speaking it only does a 
  search which is at best equivalent to a path selection. What you were
  looking for is significantly more in-depth. You were not making a fair
  comparison. IMO, XQuery is significantly more powerful than
  SQL if your SQL is fully rigged end-to-end.

  You can't use algebra to express your view unless the engine
  exposes that layer. The surface syntax is XQuery.

  rgds.

    ----- Original Message ----- 
    From: Chen Ya Bing 
    To: TAN Kuan Hui 
    Sent: Monday, February 25, 2002 16:25 PM
    Subject: Re: define views using xquery


    since I don't find  a system which support filter function, I did not test the xquery.

    the SQL equivalent depends on how we store the document into database. 

    the simplest one may be: spj(jno, sno, pno, price)
    select jno, sno, pno, price
    from spj
    where price > 100

    it is much easier than XQuery.

    for the algebra, I mean if I use algebra to express the view, it may be simplier.
      ----- Original Message ----- 
      From: TAN Kuan Hui 
      To: Chen Ya Bing ; Peter Fankhauser 
      Cc: www-ql@w3.org 
      Sent: Monday, February 25, 2002 2:29 PM
      Subject: Re: define views using xquery


      LET $p := document("spj.xml")//part[price > 100]
      RETURN filter($p/../.. | $p/.. | $p//*)

      BTW, what is your SQL equivalent for the example
      you have given ?

      NB: you can't code at the algebra layer and the surface syntax 
      at the same time. I don't think the 2 grammars can co-exist without 
      ambiguities.

      combination of XML-Schema and XQuery is not a problem.
      If you require your view function to return a typed result,
      encapsulate it in a function.

      rgds.
        ----- Original Message ----- 
        From: Chen Ya Bing 
        To: Peter Fankhauser 
        Cc: www-ql@w3.org 
        Sent: Monday, February 25, 2002 9:34 AM
        Subject: Re: define views using xquery


        one of the actual difficulties is like that:

        there is a XML document (spj.xml):
        <db>

          <project jno="j001">

            <supplier sno="s001">

                <part pno="p001">

                   <price> 100</price>

                </part>

            </supplier>

            <supplier sno="s002">

                <part pno="p001">

                    <price> 110</price>

                </part>

            </supplier>

          </project>

        </db>

         

        we want to define a view which selects such project, supplier and part that their sub element price is greater than 100.  the view definition may be:



        define view test as

        For      $j In document("spj.xml")//project[//price >100]

                     Return 

                              <project jno = {$j/@jno}>

                                { For $s In $j/supplier[//price >100]

                                   Return

                                          <supplier sno = {$s/@sno}> 

                                            { For $p In $s/part[price > 100]

                                               Return                          

                                                 <part pno = {$p/@pno}> 

                                                       {$p/price} 

                                                 </part>

                                             } 

                                          </supplier>

                                } 

                             </project>

         

        we can see that for such a simple view, we need to repeat the predicate "price >100" three times, which will lead to a very low performance of query processing, because we need to search the tree three times. the view definition is not only complex and wordy, but also low-performance.

        Is there any other way to write the query?

         

        as a view definition, one of favorite feature is that it is declarative, so that we don't need to write a very complex definition.

         

        can we just use a more simple way to write view, can XML Algebra provide any help?

         

        the view is just to put a predicate to filter some elements. if we define a view that change some structures, the view definition will be more complex.

         

        until now, we do not consider the problem of view updatability and the combination of XML-Schema and XQuery.

         

        Best regards,

         

          ----- Original Message ----- 
          From: Peter Fankhauser 
          To: 'Chen Ya Bing' ; www-ql@w3.org 
          Sent: Thursday, February 21, 2002 9:40 PM
          Subject: RE: define views using xquery


          As a starter from the scientific side you may check out
          some recent papers by Serge Abiteboul and others (one of
          Serge's favorite themes is views in all disguises).

          I'd be also be interested in the actual difficulties that you
          encountered when trying views with XQuery. In principle
          one can regard a view as a "stored" query which can be
          composed with other queries. As one of XQuery's virtues
          is compositionality, another is closure, so I wonder where exactly
          the difficulty lies.

          (1) Is it the combination of XML-Schema and XQuery that
          you (presumably) need.

          (2) Is it updatability of views that concern you?

          (3) Is it that your notion of "simple view" doesn't translate
          to an XQuery notion of a "simple query"?

          (4) Which sort of views do you want to define?

          Have you got any concrete examples, usecases, requirements?
          Where exactly do you encounter inefficiency?

          Best regards,

          Peter


            -----Original Message-----
            From: www-ql-request@w3.org [mailto:www-ql-request@w3.org] On Behalf Of Chen Ya Bing
            Sent: Donnerstag, 21. Februar 2002 10:02
            To: www-ql@w3.org
            Subject: define views using xquery


            I'd like to use XQuery as a view definition language to define XML views. but I find that it is difficult to use it as the view definition language, because a simple view definition have to lead to a complex XQuery. even more, it may be inefficient. comparing with view definition in SQL, it is inconvenient.

            can anybody give me advices of how to utilize XQuery to define XML view more efficiently?
            and how will the XQuery WD support the view facility.

            Best regards,
            Chen

Received on Monday, 25 February 2002 04:25:58 UTC