[Date Prev]
| [Thread Prev]
| [Thread Next]
| [Date Next]
--
[Date Index]
| [Thread Index]
Re: [xml-dev] XQuery & Several records (instead of one xml-field)
- From: Jim Melton <jim.melton@acm.org>
- To: "Mukul Gandhi" <gandhi.mukul@gmail.com>
- Date: Fri, 19 Oct 2007 11:04:30 -0600
Mukul,
My responses are embedded below:
At 10/18/2007 09:42 PM, Mukul Gandhi wrote:
>Hi Jim,
> Thanks for all the interesting information.
>
>Nice to know that there is now a native support for XML in SQL (the
>SQL/XML concept in the ISO/IEC spec).
>
>I have few general questions about how XQuery data model instances are
>constructed from the XML store in RDBMS.
>
> From your mail, it seems the primary means of XML storage in a RDBMS
>is via the XML data type in RDBMS Schema. And we can query this
>information using XQuery.
Absolutely correct.
However, I want to provide this disclaimer: Various SQL
implementations have various storage mechanisms that are used "behind
the curtain". For example, some systems will treat the XML type as a
character (CLOB) or binary (BLOB) string and store serialized XML in
it; others store a fully-parsed, PSVI tree in a BLOB-like structure;
still others might "shred" the document and distribute its values
across various tables and columns. But all of that is invisible to
the application writer/program.
>At the XQuery level, the XML input is converted to a data model
>instance, which the XQuery program operates on.
>
>Suppose, that a RDBMS table is defined like following:
>
>Table: X
>col1 - number (10),
>col2 - varchar2 (15),
>col3 - XMLType
>
>The column "col3" is of type XMLType (this is just illustrating the
>concept, and does not follow a syntax of a product or a standard).
Of course, it doesn't ;^)
For those of you not in on the joke, the data types shown in Mukul's
example are spelled the way that Oracle spells them, not the way that
the standard spells them. (I hasten to add, however, that Oracle
also accepts the standard's spelling as well.)
>Now the XQuery program (the XQuery engine is probably embedded in the
>RDBMS) can query the column "col3". Something like:
>
>xquery db-func:XML-column('X.col3')/root/a/b/c
True.
I would expect that the function db-func:XML-column (possible written
in some programming language with embedded SQL) would simply retrieve
the value of the column for each row in turn and pass it back up to
the XQuery environment. That is...no processing needed on the SQL side.
But, of course, that has nothing to do with SQL/XML other than the
use of the XML type.
>Now my questions are
>1) It is probably possible for a XQuery engine to reuse it's design
>(i.e. for the XML infoset/PSVI) to construct a data model instance
>from the XMLType column.
Absolutely.
>Do most of the XQuery engines embedded in the
>RDBMS work this way? Do you know how Oracle's XQuery engine in RDBMS
>work with respect to this? And how DB2's engine works if somebody can
>tell?
I can't answer about "most" ("I don't do product, I do
standards"). But I'd bet that Oracle and DB2 both use the same
overall design (parse, validate, product PSVI) as with any other
XQuery usage design.
>2) Supposing a RDBMS table is defined like this (a very simple
>traditional definition):
>Table: X
>col1 - number (10),
>col2 - varchar2 (15),
>col3 - float
>
>Can a XQuery engine work on this table structure? i.e. is it practical
>to convert a table based data to a XQuery data model instance, which a
>XQuery program can operate on?
No XQuery engine can work on that table structure *directly*. But
with the intercession of a bit of helper code, such as a function
that implements the SQL-to-XML mapping rules I mentioned in my
earlier message, or user-written code to transform that table
structure into a different XML structure, then the XQuery engine can
handle it directly.
The default rules would produce an XML document that looks something like this:
<X>
<row>
<col1>123456</col1>
<col2>abcdef</col2>
<col3>123E-1</col3>
</row>
<row>
<col1>234567</col1>
<col2>bcdefg</col2>
<col3>234E-2</col3>
</row>
</X>
(I might have some of the fine details garbled, but you get the idea.)
Hope this helps,
Jim
========================================================================
Jim Melton --- Editor of ISO/IEC 9075-* (SQL) Phone: +1.801.942.0144
Co-Chair, W3C XML Query WG; XQX (etc.) editor Fax : +1.801.942.3345
Oracle Corporation Oracle Email: jim dot melton at oracle dot com
1930 Viscounti Drive Standards email: jim dot melton at acm dot org
Sandy, UT 84093-1063 USA Personal email: jim at melton dot name
========================================================================
= Facts are facts. But any opinions expressed are the opinions =
= only of myself and may or may not reflect the opinions of anybody =
= else with whom I may or may not have discussed the issues at hand. =
========================================================================
[Date Prev]
| [Thread Prev]
| [Thread Next]
| [Date Next]
--
[Date Index]
| [Thread Index]