Shapes for Property Graphs
SHACL, taught from the ground up for people who work with Neo4j, LadybugDB and other labeled property graphs. Nine short chapters, one running example, and shapes you can compile and run at every step.
Who this is for
You know what a node, a label, a property and a relationship are. You may never have written RDF. You want the rules your graph must follow written down in one place, in a standard language, and checked automatically rather than rediscovered in production.
SHACL was designed for RDF, so most tutorials start with triples and IRIs. This one starts with your graph. Every idea is shown twice: as SHACL, and as what it means for labels, properties and relationships.
The running example
Every chapter uses one small HR graph:
(:Person {id, name, email, age, status, skills: [..]})
-[:WORKS_FOR]->(:Company {id, name, markets: [..]})-[:LOCATED_IN]->(:City)
(:Person)-[:MANAGES]->(:Person)
(:Person)-[:KNOWS {since}]->(:Person)
(:Person)-[:LIVES_AT]->(:Address {street, zip})
(:Team)-[:MEMBER]->(:Person)
All shapes live in the ex: namespace, http://example.org/hr#.
How to follow along
Install shacl2cypher (see Get started) and clone the repository. Each chapter's shapes are in doc/examples/book/, and every one of them compiles. To see the Cypher a chapter's shapes turn into:
shacl2cypher compile doc/examples/book/02-first-shape.ttl --dialect neo4j --node-key id -o out/
less out/queries.cypher
To run them against a database, swap compile for validate and add --connect bolt://… or --ladybug file.lbug.