SPARQL is not as easy to read.
I can show SQL or Cypher to some of my product managers who have experience with Excel, and they actually sort of get it. That’s not the case with SPARQL.
I can show SQL or Cypher to some of my product managers who have experience with Excel, and they actually sort of get it. That’s not the case with SPARQL.
MATCH (p:Person)
WHERE 3 <= p.yearsExp <= 7
RETURN p
or PREFIX :<my_bussines_vocab>
SELECT ?p
WHERE { ?p a :Person ;
:yearsExp ?ye .
FILTER (3 <= ?ye && ?ye <= 7)
}
Yes there is a prefix. But if well used they can be super useful. Filter interspersed with the graph pattern helps once the queries get very complicated.I have never seen a real study of Cypher being easier to read than equivalently well formatted Sparql.
MATCH (j:Person {name: 'Jennifer'})-[:LIKES]->(:Technology {type: 'Graphs'})<-[:LIKES]-(p:Person),
(j)-[:IS_FRIENDS_WITH]-(p)
RETURN p.name
or PREFIX :<my_bussines_vocab>
SELECT ?pName
WHERE {
?j a :Person ;
:name 'Jenifer' ;
:likes ?graphTech .
?p a :Person ;
:name ?pName ;
:likes ?graphTech ;
:isFriendsWith ?s .
?graphTech a :Technology ;
:type 'Graphs' .
}
The Cypher is difficult in this example because it goes both directions in the linkage, first part is read left to right, second right to left. Making it hard to decompose, and the < or > in the directions are easily missed once the queries get larger. PREFIX :<my_bussines_vocab>
SELECT ?pName
WHERE { ?j a :Person ; :name 'Jennifer' ; :likes [ a :Technology ; :type 'Graphs'] ; ^:likes ?p .
?p a :Person ; :isFriendsWith ?j }
Would be a very close version layout wise to the earlier example from the Cypher tutorial. But I don't think anyone would write that without spending some serious thought about obfuscation ;)i really have major difficulties a query that would be easier to read in SPARQL than in Cypher.
The SPARQL is more paragraph based. We are looking for ?j a :Person named 'Jenifer' and ?p a person who is a friend of ?j . Both need to be interested in graph technology.
This kind of sections of defining a query ends up easier when the relations are multitude between nodes. e.g. friends, colleagues and past having non identical lunch preferences.