15.5. Mapping Relational Data to XML

Relational databases are made up of tables of data. Each table row is known as a record. A record is made up of a fixed set of fields that can be of various types such as string, date, integer, and so on.

It is straightforward to map the tabular structure of relational database tables into XML. The simplest mapping is achieved when a table maps to a table element that can contain zero or more record elements. Each record element will contain zero or more field elements.

Let us create a simple database in MySQL. We will then develop a simple mapping to XML for arbitrary MySQL tables.

Create a new database called shoeinfo as follows.

CD-ROM reference=15005.txt
mysql> create database shoeinfo; Query OK, 1 row ...

Get XML Processing with Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.