Before you start
This tutorial is geared towards developers who want to learn how to store data in XML format in a database, connect to DB2 from a .NET application, and learn how to develop applications that leverage mapping APIs. To follow this tutorial, familiarity with the .NET framework and C# is recommended. You should also have some experience of developing with HTML and/or XML, and of communicating with a database management system using SQL. When you complete this tutorial, you will have the skills to create map-enabled .NET applications powered by a DB2 database using pureXML® to store XML natively.
Recent versions of the IBM DB2 database management system include a feature known as pureXML, which allows for XML data to be stored natively in a relational database. The concept of pureXML is unique in that it not only allows for the native storage of XML, but it also includes native processing of XML data directly in the database, as opposed to converting it into relational data or storing it as flat text. The beauty of pureXML is that it allows you to store a combination of traditional relational data that is stored in tables and columns, with document-oriented XML data, which is generally self-contained in a single XML document. IBM DB2 provides a series of methods by which you can work with this hybrid of data: SQL, SQL/XML, and XQuery.
When it comes to developing Web applications, XML is often a good choice for a data storage model as it is flexible and allows for schema changes to be made very easily without having an adverse affect on existing data. In addition, since XML is an open standard, you can easily take this data and use it on virtually any platform and development framework. Add to that the fact that many open Web services and APIs make data available as XML, and you can see why XML storage is so important when it comes to the Web.
In this tutorial, you will develop a Store Locator application using C# ASP.NET that stores its data in an IBM DB2 database. The underlying data will be stored in a database table with a relational ID column and an XML column where the actual store location data will be held. You will create relational views of this data that make it simple to use Visual Studio's data components to connect UI elements directly to your DB2 data, before learning how to import some existing XML documents into the database in bulk.
To follow the steps in this tutorial, you will need to have the following software installed:
- IBM DB2 Express-C 9.5 or later
- Microsoft® Visual Studio® 2008 (earlier versions might work but some features might not be present)
- IBM DB2 Database Add-ins for Visual Studio
See Resources for the links to download these prerequisites. When developing the .NET application, you will use the DB2 .NET provider to communicate with the DB2 server from your code. You must enable this provider before you can use it in Visual Studio, however. After you have installed both DB2 and Visual Studio, run the Configure DB2 .NET Data Provider tool as found in Start>Programs>IBM DB2>[DB2 Instance Name]>Set-up Tools.