16.10.2015 Views

Getting Started with DB2 Express-C

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 15 - <strong>DB2</strong> pureXML 291<br />

<strong>DB2</strong> also supports XML Schema evolution. This means that if your XML Schema changes,<br />

you can update the XML Schema easily <strong>with</strong> the UPDATE XMLSCHEMA command. If the<br />

changes to the XML Schema are too drastic, you are likely to get some errors.<br />

In <strong>DB2</strong> XML decomposition or “shredding” is also supported. This is the “old” method to<br />

store XML in databases, and is what other vendors use to store XML. <strong>DB2</strong> still supports<br />

this method if you wish to use it; but we recommend pureXML. <strong>DB2</strong> also supports the XML<br />

Extender, also using the old method to store XML, but this extender will no longer be<br />

enhanced.<br />

With <strong>DB2</strong> 9.7 all the benefits of pureXML has been extended to database partitions<br />

commonly used for data warehouses. Database Partitioning Feature (DPF) is offered <strong>with</strong><br />

<strong>DB2</strong> Enterprise Edition.<br />

15.6 Summary<br />

This chapter introduced you to XML and pureXML technology. XML document usage is<br />

growing exponentially due to Web 2.0 tools and techniques as well as SOA. By storing<br />

XML documents in a <strong>DB2</strong> database you can take advantage of security, performance, and<br />

coding flexibility using pureXML. pureXML is a technology that allows you to store the XML<br />

documents in parsed-hierarchical format, as a tree, and this is done at database insertion<br />

time. At query time, there is no need to parse the XML document in order to build a tree<br />

before processing. The tree for the XML document was already built and stored in the<br />

database. In addition, pureXML technology uses a native XML engine that understands<br />

XQuery; therefore, there is no need to map XQuery to SQL which is what is done in other<br />

RDBMS products.<br />

The chapter also talked about how to insert, delete, update and query XML documents<br />

using SQL/XML and XQuery. It also discussed XML indexes, XML Schema, and other<br />

features such as compression and XML Schema evolution.<br />

15.7 Exercises<br />

Throughout this chapter, you have seen several examples of SQL/XML and XQuery syntax<br />

and have been introduced to the <strong>DB2</strong> Command Editor and IBM Data Studio. In this<br />

exercise, you will test your SQL/XML and XQuery knowledge while gaining experience <strong>with</strong><br />

these tools. We will use the mydb database created using the table_creation.txt script file<br />

which was explained earlier in this chapter (Listing 15.5).<br />

Procedure<br />

1. Create the mydb database and load the XML data, as discussed earlier in the<br />

chapter. The file table_creation.txt is included in the accompanying file<br />

<strong>Express</strong>c_book_exercises_9.7.zip under the Chapter 2 folder. Run the<br />

table_creation.txt script file from a <strong>DB2</strong> Command Window or Linux shell as<br />

follows:<br />

db2 –tvf table_creation.txt

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!