Abstract
XML is the most popular data format for exchanging data, but the majority of data within applications and closed systems is still stored in Relational Database Managements Systems (RDBMS). This leads to two main issues, the first one being how moving data between XML formats and RDBMS can be done easily and efficiently, so that moving data between these two worlds can be done as easy as possible. The second issue is how to map the data models between these two worlds. Relational data can easily be represented in XML, because tables can be easily represented in trees. Things can be more complicated in the other direction, because arbitrary XML can be hard to store in a relational database. For XML-centric scenarios, XML Database Management Systems (XDBMS) are an interesting alternative, which provide XML-specific query capabilities with XML Query (XQuery).
SQL/XML Example
SELECT
e.EmpId,
e.FirstName,
e.LastName,
e.StartDate,
e.EndDate
FROM Employees e WHERE e.EmpId = 12
SELECT
XMLELEMENT (NAME "employee",
XMLATTRIBUTES(e.EmpId as "id"),
XMLELEMENT(NAME "names",
XMLELEMENT(NAME "first", e.FirstName),
XMLELEMENT(NAME "last", e.LastName)),
XMLELEMENT(NAME "hire-dates",
XMLATTRIBUTES(e.StartDate as "start", e.EndDate as "end")))
FROM Employees e WHERE e.EmpId = 12