>>Sam Hunting wrote:
>>> Can I translate this as follows:
>>> This approach allows XML data to be stored and retrieved
>>> to granularity limited only by the XML instance, using existing
>>> relational technology, with no performance penalty?
>>That was a translation? ;)
>Yes, I think it was. It was a serious question, at least.
No offence Sam! Just I had to read it three times - my fault for being
> I'm trying to
> understand where the dividing line (if any) is between the relational
> and the SGML world
I have no theoretical knowledge on this, so probably cannot help.
However, if our experience is of any use, I'd venture the following
- The 'relational world' is useful for efficient storage of connected
data. However, I would just treat it like a file-system. Build a layer
on top of it and then forget about it. The Holy Grail is objects.
- Once you have 'objects' (admittedly stored in a relational database)
you can manipulate things very easily. XML (I know nothing of SGML)
falls out frighteningly easily.
So, the 'dividing line', (if any) of interest to me is that separating
objects and XML.
> working from the assumption that content that's worth
> normalizing goes in the database, and content that isn't, doesn't.
Again, very interesting. I can only refer you to my comments on the
Oracle document on XML in relation to normalising. Again, my theoretical
knowledge is limited, but I think that normalising is beginning to mean
something different to what it traditionally does. To me what is of more
interest is that two apparently different pieces of data are known to
convey the same meaning:
"You owe me twenty <CURRENCY ISO="USD">bucks</CURRENCY>", said the
debt-collector. "I can give you ten <CURRENCY
ISO="USD">dollars</CURRENCY> now", I replied. "Please don't break my
(Hey, it's nearly Xmas - forgive me if my imagination wanders!)
Now that isn't traditionally what we'd mean by normalisation - and maybe
it isn't what we mean now either - but it implies to me that just about
everything could benefit from going into a database.
> You seem to have thought through an approach to this design problem,
> interested to understand it.
> So, (1) Here is what I see as a claim of unlimited granularity:
> "allows you to distribute any node in the tree"
> And (2) since you don't mention performance issues... I assume there
> any ;-)
It is surprisingly fast. For example, retrieving an object is pretty
easy. If we have:
<STREET>39 Whitfield Street</STREET>
This can be (almost) represented by:
OBJECT TABLE DEFINITION
Field 1 ID
Field 2 Parent
Field 3 Name
1 0 COMPANY
2 1 NAME
3 1 ADDRESS
4 3 STREET
Then to retrieve all immediate children of the COMPANY object just do:
SELECT * FROM tblObject as o1, tblObject as o2
WHERE o1.ID = o2.Parent
AND o1.Name = "COMPANY";
My SQL is rusty, so I've probably made a mistake - need JOINs and
whatnot - but you get the picture. (Anyway, the fact that my SQL could
be rusty after so many years of using it shows the advantages of
building a layer on top of the relational database and then just
forgetting about it!)
From this you can see that it takes the same amount of time to find any
node in the tree, no matter how deep. Of course, if you want to keep
drilling down then you would need to keep calling the select statement
above with each child value tested against the parent values. (Get a bit
of performance improvement by using the results of the select in a WHERE
... IN.) Other advantages of this layout are being able to find data in
different parts of the tree, for example, all companies in London.
By the time you've added a few indexes to this structure (and a couple
more tables - it's not quite as simple as outlined here) it is pretty