Why Explain the Object Model Here?

Why examine the object model when reading about XML? The answer is that XML document structure is very similar to the object model for data. XML structure can easily be misconstrued as being more akin to a hierarchical data structure, rather than an object data structure. However, in a hierarchical data model one must always begin at the root of a data structure and search the entire structure for what is being selected from the database. With an XML document this is not the case. When parsing through an XML document, the human eye does not pass through the structure of the document, but rather searches for patterns in strings in a left to right, and top to bottom fashion. In other words, you dont build a hierarchical structure in your mind as you glance at an XML document. I dont anyway. Some may do that kind of thing because it interests them. That kind of mental gymnastics doesnt interest me unless I think it is necessary to the task at hand.

Why explain all this by discussing the scanning of an XML document by eye? Because that is how a parsing expression, such as a simple Perl script, would probably search an XML document for a specific value. Therefore, it could be said that scanning for a specific value in an XML document does not necessarily involve building the data hierarchy and then mathematically traversing that hierarchy.

Why explain the object model for a database? It will help you to understand the basic structure of an XML document. An XML document allows the containment of entire structures (subtrees) within a single node (parent node). This containment aspect is true for any of the nodes in an XML document. The only exceptions are the root node, which has no parent node, and the leaf nodes, which have no child nodes. A relational database structure, when built using something like a text file, such as an XML document, results in a flattened or two-dimensional structure. In a two-dimensional structure one cannot contain subtree nodes in a single parent tree. That type of structure is completely contrary to a normalized relational database structure.

A normalized structure attempts to establish complex (not contained), inter-relationships between objects for the purpose of removing duplication from data.

XML document structure does not necessarily remove duplication from data. At least it is not quite as fussy as a relational table structure. By examining the object model as applied to data in this chapter, you will gain a better understanding of XML documents, how they can be used and how they can be accessed. So, lets take a look at a very simple conversion of relational data into an XML structure.



Beginning XML Databases
Beginning XML Databases (Wrox Beginning Guides)
ISBN: 0471791202
EAN: 2147483647
Year: 2006
Pages: 183
Authors: Gavin Powell

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net