4

XML is labelled tree, a special case of graphs. So, why there are separate XML databases and why is it that XML is not stored in graph databases? At a first glance it seems so easy - one should map XML parsing and storing operations to graph database insert/update operations and one should translate XQuery queries to the Gremlin queries. There could be small layer that can convert every graph database into XML database. It seems so easy and self-evident. But, as far as I have searched the Web, there is no such layer. All the XML databases are not just layers atop graph database, they are standalone projects.

This question about differences between XML and graph databases is even more actual when one observes that there are just few (unconvincing) open source XML databases whose scalability can be an issue (and there is one very reliable commercial XML database - Clusterpoint, I guess that BaseX is the most serious open source XML database) but there are several very scalable and serious graph databases (e.g. JanusGraph). So, maybe creating the mentioned layer atop a scalable open source graph database is the viable path to create scalable open source XML database?

Generally, do graph and XML databases use completely different algorithms in their implementation? What makes them different and why can one not consider/implement an XML database as just a specialization of the graph database?

I am asking just about general concepts and about names of algorithms, no specifics are required.

  • XML is a human readable format that can perfectly be stored like this on its own, and eventually build indexes around it. However for a huge set of data, you would prefer to use an RDBMS, which perfectly stand to handle metadas, and relation betweens objects (even hierarchic now). It's more used to echange data between system than store them. And of course there is the specific case of HTML. – Walfrat Oct 10 '17 at 20:34
  • 2
    Just because two things can be mapped down to a similar or even identical mathematical structure, doesn't mean that they both benefit from the same abstractions of use. Simply put, XML data usually isn't used to store and query a "nodes and edges" data structure. – whatsisname Oct 10 '17 at 20:34
  • 3
    What isn't a special case of graphs? Isn't RAM just a graph database? – immibis Oct 11 '17 at 0:07
6

The terms XML database and graph database describe the use cases of each kind of database. The XML database is intended to store and search XML documents. Graph databases is intended to represent a graph model of nodes and edges. While an XML document is a tree, users of XML think of XML as a document and not as a set of nodes and edges. The XML database is more similar to a document-oriented database

XML databases are a subclass of document-oriented databases that are optimized to work with XML documents. Graph databases are similar, but add another layer, the relationship, which allows them to link documents for rapid traversal. -Document-oriented database

Another key difference is that in an XML database it's not important to share nodes. For example if I have two XML documents that look like this:

<!-- doc 1 -->
<document id="1" foo="bar"/>

<!-- doc 2 -->
<document id="2">
  <element foo="bar" />
</doc>

The XML database wouldn't allow me to link the two documents through their relationship of attribute value bar of type foo, whereas in a graph database, I could model it in that way

enter image description here

The Bar node is shared and we can query for all nodes connected to Bar. In an XML database, that's intentionally not possible.

While an XML database could internally be stored in the same way as a graph database, it probably wouldn't be a good fit because the difference in access patterns. In an XML database users will be updating entire documents where the structure could change dramatically, and they'll be searching for documents that match certain values in certain nodes. With a graph database users will be updating relationships, changing nodes, and they'll be traversing relationships.

Most databases can be used to model other kinds of databases. For example a relational database can be used to represent a graph (see sql-g). A graph database could represent an XML document. The key difference between database types is their focus and intended access patterns that they've designed the database for.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.