Modern RDBMS\'s have support for XML column types and functionality for dealing with XML in stored procedures. Historically I would always have mapped hierarchical data (whe
I've not had the need to store XML so far, but I frequently use the ability to return XML from a stored procedure. It makes some things very useful - mainly reports. I can run a SP to generate the report, send back the results in XML, and then use XSLT to display the result on the site very easily.
For example, you get XML documents from some other system, with very rich or complex structure that you want to store; but you only need a few well-defined queries to retrieve that data. In that case, just parse the data you need to generate some indexes, and store the whole XML structure in a single field.
To do that you don't need much XML-specific support on the DB engine, but it still helps to keep queries expressive.
Besides that, I'd guess some DMBS with good XML support could let you simply store the XML document, maybe without specifying how to index it. You just use XQuery and hope it somehow optimises to your needs.
You can process XML data directly in SQL server. E.g. you can apply XPath expressions and just send the filtered result set to the client. SQL server features can build upon XML processing capabilities later.
The features above exist from MS SQL Server 2000 or 2005.
Here is a real world example from a system I work on. We have a core system and create customer-specific code in java. A different class may be called depending on which customer is transacting. Sometimes this custom code needs to store something and we put it into an XML column in the relevant table. This saves us from modeling everything under the sun. Adding a new customer generally just means writing and installing the java code.
The downside is that reporting, querying and updates are more difficult on the XML column. There are none of the usual good database features like check constraints, etc.
Let's say you have an entity that has attributes. You can store all those attributes in XML instead of creating a separate attribute table. The XML would be more flexible.