Before you start
The target audience for this tutorial is PHP and Java developers who use XML and want to learn about native XML databases (ibm®db2®express-c 9.5 in this tutorial). While it is helpful to know more about PHP and Java programming, unfamiliar with these techniques does not affect the reading of this tutorial. It's also helpful to be familiar with XMLDOM.
About this tutorial
This tutorial explains how to compress the development cycle with native XML databases. As an example, we will modify the XML schema and observe the corresponding changes in the code. Developers will learn the basics of using native XML databases in PHP and Java technology, including:
Connect to Database (DB2 express-c 9.5)
Storing and retrieving XML data
Create a table to write new data in a one-way database
Create a form to read existing data from a database
Querying a database using Sql/xml
Enhanced Data View supports quick query capabilities
Modify Database Schema
Avoid modifying the database
To learn and grasp the above concepts, we will create several WEB applications, where the PHP code section lets users enter and view patient data, and the Java Code section enters and views the doctor's information.
Prerequisite conditions
In addition to text editors and browsers, you need the necessary tools to support Java and PHP servers:
Java JDK, download the latest JDK from Sun to run and compile Java code. This tutorial uses JAVA6, upgrade Pack 5.
Apache Tomcat, as a WEB server hosting Java applications. This tutorial uses the 6.0.16 version.
PHP, the latest version of PHP, was written in 5.2.5.
Apache2, it is recommended that you use Apache2 as the HTTP server for PHP.
Operating system is not limited. This tutorial is written on a machine running Windows vista®ultimate.
DB2 express-c 9.5, the database used in this tutorial. You can use any native XML database such as Apache Xindice.
Brief introduction
This section describes what a native XML database is and its impact on development. The main features of DB2 Express-c 9.5 will also be introduced and the Quick Installation Guide is provided.
Why use Native XML databases?
Once you've used a native XML database, you'll never give up. Especially if you've ever decomposed all the data from XML and plugged it into a non-XML database, then retrieved the data and then made the original XML file. Or, you have completed 90% of a project, just because you found that you need to add a new field (or modify the pattern), this unfortunate accident means you have to drill down into the database to create a new field. Then iterate through all the SQL strings to insert the new field, and even have no time to focus on whether the code needs to make the necessary modifications. If you use a native XML database and you need to change the database schema, the only thing you need to focus on is to modify the code (no database or SQL string changes are required)!
This shows that native XML database has great advantages in saving development time and developing cost. In this tutorial, you will experience this savings by entering and viewing the PHP application of patient information and the two examples of Java applications that enter and view physician information.
As mentioned earlier, any native XML database is suitable for the examples in this tutorial. But I chose DB2 express-c 9.5, so here's how to quickly install Express-c to start writing code.