On 2/25/17, 12:55 PM, "Liam R. E. Quin" liam@w3.org wrote:
On Sat, 2017-02-25 at 10:02 +0000, Kendall Shaw wrote: > It’s interesting to me to know what sorts of applications seem like > they would be a good match for XQuery’s data model but turned out not > to be in some case.
I agree that's interesting - I'm afraid I have more experience with what didn't work in SQL and did work with a forest store, probably because I don't often encounter people whose projects didn't fit with XML-related technologies. How do we find them?
Aside from things like the 100,000 sensors scenario that you described, the friends example might be a case that is in the same area that XML makes sense.
With XPath having special support for hierarchical data, matching XML’s notion of element hierarchy, it’s perfect for data like:
<totem-pole> <person name=”cindy”> <person name=”karen”> <person name=”linda”> <person name=”sarah”> <person name=”wendy”/> </person> </person> </person> </person> </totem-pole>
So you can us $person//*/@name to get cindy’s sub-friends. Also, the document is constrained to be well-formed by the rules of XML document types, based on elements having only 1 parent. But, friends aren’t constrained to have only have 1 super-friend. And poor Wendy gets no sub-friends.
A less restricted graph representation can represent that where hierarchy doesn’t have special status:
@prefix : <people#> . :cindy :name “cindy” ; :knows :karen . :karen :name “karen” ; :knows :linda . :linda :name “linda” ; :knows :sarah . :sarah :name “sarah” ; :knows :wendy . :wendy :name “wendy” :knows :cindy .
And with SPARQL, having special support for graph traversal, matching RDF’s notion of connected edges, it’s perfect for data like above.
So, you can use ?p :knows/:name ?name to get cindy’s friend’s friend’s friend’s friend’s etc. Also, Wendy gets to have a friend too.
Representing something similar in XML, ignoring RDF XML which makes it even more complicated:
<friends> <person name=”cindy” knows=”karen”/> <person name=”karen” knows=”linda”/> <person name=”linda” knows=”sarah”/> <person name=”sarah” knows=”wendy”/> <person name=”wendy”/> </friends>
The rules of XML document types don’t include special support for arbitrary attribute relationships, in the way that element hierarchy does have special status. You can write XQuery to navigate that data, but it’s not a simple expression and doesn’t use ancestor/descendant axes so maybe it’s not the best choice for the data.
The other way around, when most of the data is hierarchical it’s harder to use something like SPARQL with RDF than XPath with XML. And RDF is not necessarily the best representation for graphs where nodes and edges both have attributes.
Kendall