Before you start
This tutorial is for Web application developers who want to develop database-driven applications that are powered by an IBM DB2 database. You should be familiar with basic HTML, CSS, and PHP code in order to follow the tutorial. You should also have some experience with database management systems and the SQL language.
One of the most useful and versatile technologies available in IBM DB2 is its native support for XML data through the pureXML feature. PureXML allows you to store, retrieve, and manipulate XML data alongside and in the same manner as relational data. This enables you to develop applications that harness the advantages of both relational databases and XML data. Such applications can be particularly useful when you have a large amount of XML data that you need to leverage without having to first convert it into a relational structure.
This tutorial gives you step-by-step instructions on how to use PHP to create a Support Knowledge Base system that stores its data using a combination of traditional DB2 relational columns and pureXML columns. The application uses the power of SQL/XML to map XML data as a relational column. This allows you to use PHP to retrieve the data as though it were stored in a relational manner.
The tutorial instructions are written with the assumption that you are creating the application on a local development server running Windows® XP with DB2 Express-C, Apache HTTP Server, and PHP installed. You should be able to adapt the instructions to other systems and configurations, but they have not been tested.
The directory structure for the application is relatively simple. You will store the application in a subdirectory named kbase in your Apache installation's htdocs directory. On Windows systems, this directory is commonly found in the path C:\Program Files\Apache Software Foundation\Apache 2.2\htdocs. Beneath the kbase directory there will be four subdirectories:
- classes — contains the PHP classes that are used to pull data from the database and into the application.
- css — includes the CSS style sheet file that defines the look and feel of the Web application's user interface.
- includes — contains files with the code for the application's header, navigation sidebar, and footer. PHP scripts include these files at the start and end of each page so that you don't have to copy the same code into each page's source file.
- sql — contains the database SQL script that creates the DB2 database and its tables. You will use this script in the next section of this tutorial.
The application contains a series of Web pages that can be categorized as follows:
- Administration view — contains pages that allow you to create and manage categories, articles, and comments.
- Client (end user) view — contains the application home page, the search results page, and the pages for viewing a category and details of an article.
In order to follow the steps in this tutorial, you need to have the following software installed:
A thorough guide to installing and configuring the above software is available in the developerWorks article series, "Leveraging pureXML in a Flex microblogging application" (see Resources for a link). Part 1 of this series shows you how to install DB2 Express-C. Part 3 has in-depth instructions on installing Apache HTTP Server and PHP.