Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

XML vs. database

 
lydia westland
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've seen XML is useful as a data exchange mechanism, as a format tool, and for the seperation of content and structure. but as a data storage, I have two questions:
1. I am thinking database has more advantage over XML, is that true? For example, database has a lot of tools and may be faster in querying.
2. I've never use the import XML function in database. XML employs tree structure, while most commercial database user tables and relationships, how do they import "XML"?
Thank you for explaination
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It seems a strangely common assumption that XML is some sort of database. However XML is not a form of data storage, it is a form of data markup. Even if you mark up your data in XML, you still have to store it somewhere if you want to keep it around. An XML document-tree can be stored in a text file, for example, or it can be stored in a database, or it can be stored in a LDAP repository, or whatever.
Considering databases in particular, there are essentially two ways of storing XML-marked-up data in a database :- as whole documents; or decomposed.
To store some XML data as a whole document you might export a DOM tree as a text file and store it in a CLOB or BLOB column.
To store a decomposed XML document you might either use domain knowledge to represent the same data in a relational form, or simply "flatten" the document into a key/value map and store that in a table. "Flattening" is something a lot of XML users are not very aware of, but works like this:
Take an XML tree, for example:
<team>
<person sex='male'>
<name>Frank Carver</name>
<location>England</location>
</person>
<person sex='female'>
<name>Mapraputa Is</name>
<location>USA</location>
</person>
</team>
When "flattened" it might look like
team.person[0].@sex=male
team.person[0].name[0]=Frank Carver
team.person[0].location[0]=England
team.person[1].@sex=female
team.person[1].name[0]=Mapraputa Is
team.person[1].location[0]=USA
Note that the exact method used to generate the left-hand side "key" varies, but the important thing is that it encodes enough information to regenerate the same XML document.
 
Devrim Turker
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://www.cs.washington.edu/education/courses/cse326/01sp/lecture8.ppt
http://www.cs.washington.edu/education/courses/cse544/00sp/lectures/ppt/l3.ppt
hypersonic database (used by jboss) uses AVL tree
for storage
sapdb also uses AVL tree.
perhaps indexing logic is used for storage now
have fun
 
Mapraputa Is
Leverager of our synergies
Sheriff
Posts: 10065
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. I am thinking database has more advantage over XML, is that true? For example, database has a lot of tools and may be faster in querying.
Abolutely. Here is my canned list of database virtues:
transactional integrity
security
authentication
concurrency control
data validation and conversion
search mechanism
XML was created as a substitution for HTML to allow "meaningful" markup, so search engines could do better job etc. Looking at what it becomes... Here is a quote from XMLHack: "Edd Dumbill opens the XML Europe 2002 conference by questioning whether XML has become the "SGML on the Web" which it was meant to be.
"XML has achieved more than we could believe and is even ridiculously widespread to the point that we find it in the configuration files of our PC. It's been used to integrate to web web cell phones and set top boxes and is even been taught in the universities. "
http://xmlhack.com/read.php?item=1654
2. I've never use the import XML function in database. XML employs tree structure, while most commercial database user tables and relationships, how do they import "XML"?
To add to what is already said, chances are that imported XML is nothing but another database's unload - i.e. the very tables represented as a tree. I would love to see statistics on what percent of XML documents have table-like nature.
--------------------
"There are no answers, only cross references."
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic