Q&A
Q. |
Don't some databases provide features specifically for handling XML? |
A. |
Most major relational databases (like Oracle, Microsoft SQL Server, and IBM's DB2) support XML natively. The problem is that none of them support XML in the same way. If you use a database that provides XML support, you should look at the vendor documentation and decide whether you want to use it. The specific XML support in each of those databases is unfortunately beyond the scope of this lesson. |
Q. |
What about object-oriented databases? Aren't they better suited to use with XML? |
A. |
Object-oriented databases are more appropriate for storing XML data than relational databases, generally speaking. They're designed explicitly to handle the treelike data structures associated with object-oriented design. Treelike is also the best way to describe most XML data structures. However, object-oriented databases have not displaced relational databases on the market and are not standardized in the same manner as relational databases. |
Workshop
The Workshop is designed to help you anticipate possible questions, review what you've learned, and begin learning how to put your knowledge into practice.
Quiz
1. |
What SQL statement do you use to retrieve data from a database? |
2. |
What is the drawback to exporting a database table as an XML document, such as was done in this chapter using phpMyAdmin? |
3. |
Why is it a good idea to break down XML documents used for data storage into tables when storing the data in a relational database? |
Quiz Answers
1. |
The SQL statement used to retrieve data from a database is the |
2. |
The drawback to exporting a database table as an XML document is that you typically have to do it manually, which isn't ideal for web applications that need to query a database for XML data dynamically. Furthermore, exporting an entire table is usually less useful than targeting data that matches a specific query. |
3. |
When you use XML documents for data storage, it's a good idea to convert them into tables when using a relational database so that you can take advantage of SQL when you're retrieving data from the database. |
Exercises
1. |
Set up your own MySQL database, and then modify the PHP example from this lesson to work with it. |
2. |
Try passing in different parameters to the PHP example to alter the SQL query, and therefore the resulting XML file. |