4 ms·
That is more a question of formatting your queries. I can show SPARQL to our data analyst and biologists and they get them. Equivalent Cypher is supper confusin
by jerven 7y ago
That is more a question of formatting your queries. I can show SPARQL to our data analyst and biologists and they get them. Equivalent Cypher is supper confusing because the queries tend to be quite large and the space between the MATCH and WHERE sections as done in the queries I have seen makes it hard to follow.
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 ;)
- baq 7y agoFWIW in your second example i was able to understand the Cypher query without so much as a double take and i still don't quite get the SPARQL query. i really have major difficulties a query that would be easier to read in SPARQL than in Cypher.
- jerven 7y agoOk, fair enough. I suspect the typo in the sparql query doing the key join isn't helping :( 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.
- dunefox 7y agoI have never seen either of those languages and Cypher is much easier to understand.