[Date Prev]
| [Thread Prev]
| [Thread Next]
| [Date Next]
--
[Date Index]
| [Thread Index]
Re: [xml-dev] XML vs relational database
- From: Jim Melton <jim.melton@acm.org>
- To: Sylvain LOISEAU <sylvain.loiseau@wanadoo.fr>
- Date: Thu, 16 Aug 2007 09:47:40 -0600
Sylvain,
At 8/16/2007 08:01 AM, Sylvain LOISEAU wrote:
> >> Don't you think there is a structural
> >> difference, from this point of view, between XML and DBMS?
>
> > Sure, in SQL all the instances have the same structure, so the structure
> > information can be stored separately from the instances.
>
>Ok. But I'm not sure to have completly understand. With SQL, there
>is no need to store the structure information with the instance, but
>is this _possible_?
Well, in a sense, yes. The tables and views in the Information
Schema are self-describing. That is, there is a TABLES table that
describes all of the tables in the database...including
itself. Therefore, for the row in the TABLES table that describes
the TABLES table, the structure information is stored with the
instance -- in fact, it *is* the instance.
I agree: that isn't a real answer to your question, but a very
trivial subcase. However, a slightly more meaningful response would
be this: It is possible in the SQL standard to join rows of table T1
with the row in table TABLES that describes table T1. The resulting
rows returned to the query will contain columns from TABLES whose
values describe the structure of the remaining columns in those
rows. Is this really useful, though? I submit that it is unlikely
to be useful in many situations.
An important difference between XML and SQL (and the relational model
itself) is that the values stored in an SQL table are entirely
regular -- every single row in a given table has the exact same
structure, so one need to access that structure information only once
for possibly trillions of rows. By contrast, the structures of XML
documents -- even those that are valid against a single schema --
often vary wildly within a collection; if the only criterion is
well-formedness, then the wildness gets infinitely wilder. Of course
I just described those characteristics in a way that makes SQL look
"better", but the exact same characteristics can be turned around to
say that rows in an SQL table are extremely inflexible and cannot be
used in situations where the precise structure of data is not
well-known in advance, while XML schemas can be designed to allow
very flexible data structures that can even be extended by other
schemas to make things even more flexible. Which is better? Both of
them, of course! Which is worse? Same answer!
>For instance, one can ask for a structural property of the tree, in
>XPath, say the name of an element, by (1) referring to this element
>by its position and (2) using local-name() :
>local-name(./children[1]). In a relational algebra model, there is
>no order of the field, if I understand correctly. I see no other way
>of adressing a field than by its name.
It is true that in the relational model of data, attributes (columns)
have no order with a relation (table). However, in the SQL model,
columns are, in fact, ordered. In spite of that, the SQL standard
strongly(!) discourages code that depends on the sequence of columns
within a table. Technically, you're not quite right, but in practice
you are absolutely correct.
>I'm not sure I'm saying something trivial (a set doesn't have the
>properties of a tree) or not (there is a structural difference
>between sql and xml regarding the relation between data and metadata).
The trivial is certain true and incredibly important to understand
when designing a data management application. The latter can be more
subtle, but is equally true. The beauty of SQL (there I go again) is
that it is impossible, even in theory, to separate data from the
schema that describes the data, while XML data has no inherent schema
information other than an explorable structure and any schema
information that is provided is inherently separate from the
data. There is exactly one, no more and no fewer, schema that
describes each SQL row, but there many be arbitrarily many schemas
that correctly describe any given XML document.
Hope this helps,
Jim
========================================================================
Jim Melton --- Editor of ISO/IEC 9075-* (SQL) Phone: +1.801.942.0144
Co-Chair, W3C XML Query WG; F&O (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]