Database Reference
In-Depth Information
insert into dbo.XMLTypedDemo(XMLData)
values(/*XML From Listing 11-1*/);
create primary xml index XML_Primary_XmlTypedDemo
on dbo.XmlDemo(XMLData);
Now let's look at the primary XML index for the typed XML shown in Figure 11-3 .
Figure 11-3. Primary XML Index data (typed XML)
As you see, the primary XML index now has just sixteen rows—a single row for each XML node in the original
data. It also has the type information specified for every node ( tid column).
Let's compare the storage space required for element- and attribute-centric XML for both the typed and untyped
XML. Let's create two XML Schema collections and four tables with primary XML indexes. Then we will populate
these tables with 65,536 rows of data. The code in Listing 11-6 shows all of these steps.
Listing 11-6. Comparing storage space required for both typed and untyped XML
create xml schema collection ElementCentricSchema as
'<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Order">
<xs:complexType>
<xs:sequence>
<xs:element type="xs:int" name="OrderId"/>
<xs:element type="xs:float" name="OrderTotal"/>
<xs:element type="xs:int" name="CustomerId"/>
<xs:element type="xs:string" name="OrderNum"/>
<xs:element type="xs:dateTime" name="OrderDate"/>
<xs:element name="OrderLineItems">
<xs:complexType>
<xs:sequence>
<xs:element name="OrderLineItem" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element type="xs:int" name="ArticleId"/>
<xs:element type="xs:int" name="Quantity"/>
<xs:element type="xs:float" name="Price"/>
 
Search WWH ::




Custom Search