Skip to content

Thinking in Triples

Querying the Graph

10 min+95 XPStep 1/11

A graph query is a shape to match

Cypher reads like ASCII art of the pattern you're hunting: MATCH (p:Person)-[:WROTE]->(b:Book)<-[:WROTE]-(q:Person) WHERE p <> q RETURN q — 'find co-authors.' You're describing a subgraph shape; the engine finds everywhere it occurs.

SPARQL does the same for RDF with triple patterns: ?person :wrote ?book . ?book :genre 'Sci-Fi' — every ? is a slot to fill. Both are declarative pattern matching, not procedural navigation: you declare the shape, the planner finds it. Thinking in shapes — not loops — is the mental shift.