Attention: open in a new window. PDFPrint

- 15 Minute Introduction -
When to use XML Instead of a Relational Database
Room4me.com Software LLC

By Frank Font 2005
This document may be quoted and copied freely when appropriate authorship attribution is also included. Disagree with the content? Email This e-mail address is being protected from spambots. You need JavaScript enabled to view it

What is XML?

XML is the abbreviation for Extensible Markup Language. This is an open and popular standard for marking up text in a way that is both machine and human readable. By “marking up text” we mean that the data in the text files is formatted to include meaningful symbols that communicate to a reader what that data is for. The syntax of XML is similar in style to HTML, the markup language of the World Wide Web (WWW).

The data in an XML file can be organized into hierarchies so that the relationships between data elements are visually obvious. The data and the structure are always presented together. XML is intuitive once a few simple syntax rules are understood. Designing a good XML structure is something a non-technical business subject matter expert can do after minimal instruction.

Beyond simple XML text, there are related technologies such as XML Schemas (XSD) and XML Transformations (XSL). These technologies complement XML text documents by adding value in the areas of validation and processing.

What is a Relational Database?

A relational database is a powerful data storage and retrieval technology where data is stored as rows in tables and the database has one or more tables. Each row of a table has the same columns as every other row in that table. Data is related between tables using the concept of “foreign keys” so that data in a row of one table can be associated with one or more rows of another table.

Data in a relational database is readable by executing SQL queries in a management tool to extract and present the data in any number of ways. The extraction requires an understanding of the database structure, including the foreign key relationships. Designing a good non-trivial relational database requires significant training and/or significant experience with relational database design techniques.

What do they have in common?

Both XML documents and relational databases store data. Both have established techniques for extracting the data they contain.

What does a relational database do better?

Relational databases are better for handling large volumes of data within a system. They have mature management systems that can efficiently and reliably maintain large quantities of structured data. This data can be updated via transactions that ensure the integrity of the database and the content can be extracted very quickly when properly configured. There is no equivalent XML management system, and using XML documents directly for storing and maintaining large volumes of data can prove both inefficient and unreliable.

What does XML do better?

XML documents contain both the data and the informative relationship structuring of that data in a way that both machines and people can read. An XML document can be electronically transmitted from one party to another and all the information is carried with it, so they are self describing. Databases, although self-describing to a knowledgeable database technologist using appropriate tools, are not generally transmitted in their entirety from one party to another.

Since XML does a very good job of delivering self-describing data feeds it has become a key standard in Service Oriented Architectures (SOA) and Web Services.

Summary

Consider using a relational database within a system to manage and maintain a large data store, or to manage a data store that is regularly updated by various users. Use XML as the format of data that is delivered to client programs and between components of a distributed system. Creating XML documents from relational database queries is a natural way to combine both technologies.

Revision History

DateDescription
20050909Initial release.
20050911Minor language updates.