Write your shapes graph (left) and data graph (right) in Turtle syntax. Use the preloaded examples or start from scratch.
Quick-reference material from the book. Pick a topic below.
| Category | Constraint | SHACL Property | Description | Example Value |
|---|---|---|---|---|
| Shape | Property | sh:property | Links a node shape to its property shapes | rule:Book-author |
| Shape | Node | sh:node | Inherit constraints from another node shape | rule:Work |
| Shape | Qualified Value Shape | sh:qualifiedValueShape | Constraints for a number of value nodes conforming to a shape | [ sh:class ex:Finger ] |
| Value Type | Class | sh:class | Value node must be instance of given class | foaf:Person |
| Value Type | Datatype | sh:datatype | Value node must be literal of given datatype | xsd:integer |
| Value Type | Node Kind | sh:nodeKind | Value node must be IRI, Literal, or BlankNode | sh:IRI |
| Cardinality | Min Count | sh:minCount | Minimum occurrences of the property | 1 |
| Cardinality | Max Count | sh:maxCount | Maximum occurrences of the property | 1 |
| Value Range | Min Exclusive | sh:minExclusive | Value must be > given value | "1999-12-31"^^xsd:date |
| Value Range | Min Inclusive | sh:minInclusive | Value must be ≥ given value | 0 |
| Value Range | Max Exclusive | sh:maxExclusive | Value must be < given value | 10000 |
| Value Range | Max Inclusive | sh:maxInclusive | Value must be ≤ given value | 10000 |
| String | Min Length | sh:minLength | Minimum character count | 2 |
| String | Max Length | sh:maxLength | Maximum character count | 11 |
| String | Pattern | sh:pattern | Must match regular expression | "^(?:\d{9}[\dX]|\d{13})$" |
| String | Language In | sh:languageIn | Language tag must be in given list | ("en" "no" "de") |
| String | Unique Lang | sh:uniqueLang | Only one value per language tag | true |
| Prop. Pair | Equals | sh:equals | Values must equal those of another property | ex:mainTitle |
| Prop. Pair | Disjoint | sh:disjoint | Values must not overlap with another property | ex:editor |
| Prop. Pair | Less Than | sh:lessThan | Value must be less than other property's value | ex:secondEdition |
| Prop. Pair | Less Than Or Eq. | sh:lessThanOrEquals | Value must be ≤ other property's value | ex:endDate |
| Logical | Not | sh:not | Must NOT conform to given shape (negation, ¬x) | rule:Agent-status |
| Logical | And | sh:and | Must conform to ALL shapes in list (x ∧ y) | ( rule:A rule:B ) |
| Logical | Or | sh:or | Must conform to at least ONE shape (x ∨ y) | ( rule:A rule:B ) |
| Logical | Xone | sh:xone | Must conform to exactly ONE shape (x ⊕ y) | ( rule:A rule:B ) |
| Other | Closed | sh:closed | Only declared properties allowed | true |
| Other | Ignored Properties | sh:ignoredProperties | Properties excluded from closed check | (rdf:type) |
| Other | Has Value | sh:hasValue | At least one value node must equal given value | ex:Fantasy |
| Other | In | sh:in | Value node must be in given list | ( ex:Fantasy ex:SciFi ) |
| Target | SHACL Property | Targets |
|---|---|---|
| Target Class | sh:targetClass | All instances of a class |
| Target Node | sh:targetNode | One specific node |
| Target Subjects Of | sh:targetSubjectsOf | All subjects of a property (domain) |
| Target Objects Of | sh:targetObjectsOf | All objects of a property (range) |
| Implicit Class Target | Shape typed as rdfs:Class | The class itself is the target |
| Path Type | SPARQL | SHACL (in sh:path) |
|---|---|---|
| Predicate | iri | sh:path ex:author |
| Inverse | ^iri | sh:inversePath ex:author |
| Sequence | a/b | ( ex:author ex:name ) |
| Alternative | a|b | sh:alternativePath ( a b ) |
| Zero-or-more | a* | sh:zeroOrMorePath ex:a |
| One-or-more | a+ | sh:oneOrMorePath ex:a |
| Zero-or-one | a? | sh:zeroOrOnePath ex:a |
A one-day introduction to SHACL. About 4½ hours of instruction, with roughly a third of it (~90 minutes) spent hands-on in this playground. The rhythm is deliberate: ~35 minutes of teaching, then a hands-on, then a debrief — repeated.
| Time | Duration | Block | Hands-on |
|---|---|---|---|
| 09:00 – 09:20 | 20 min | Introduction | — |
| 09:20 – 10:15 | 55 min | Why SHACL (use cases, motivation) | — |
| 10:15 – 10:30 | 15 min | ☕ Break | — |
| 10:30 – 11:30 | 60 min | Shapes, targets & paths (Ch. 5) | Exercise 1 |
| 11:30 – 12:30 | 60 min | Core constraints I (§6.1–6.5) | Exercises 2, 3 |
| 12:30 – 13:30 | 60 min | 🍽️ Lunch | — |
| 13:30 – 14:30 | 60 min | Core constraints II (§6.6–6.8) + SHACL engine (Ch. 8) | Exercises 4, 5, 6 |
| 14:30 – 14:45 | 15 min | ☕ Break | — |
| 14:45 – 15:00 | 15 min | Free practice & wrap-up | Capstone |
Six exercises plus a capstone challenge, sequenced to match the teaching blocks. 1 follows Shapes & Targets, 2–3 follow Core Constraints I, 4–5 follow Core Constraints II, and the Capstone is for free practice. See the Exercises tab.
Introduction + Why SHACL. Set the scene: OWA vs. CWA, where SHACL fits alongside OWL, the data-pipeline architecture. Use cases and motivation — why validation matters.
Shapes, targets & paths (Ch. 5). Node vs. property shapes, target kinds, property-path kinds, and the linking convention. Lord of the Rings as the running example. Then Exercise 1 — deliberately small, a "does everyone's setup work?" checkpoint.
Core constraints I (§6.1–6.5). Value type, cardinality, value range, string-based. Then Exercises 2 and 3 back-to-back. Exercise 3 is where the Turtle-string escaping gotcha for sh:pattern bites — a good pain point to have in class.
Core constraints II (§6.6–6.8) + SHACL engine (Ch. 8). Logical constraints with the truth tables (walk them live — see the Reference → Logic tab), then sh:closed, sh:hasValue, sh:in. Segue into the SHACL engine: validation report structure, result vocabulary, severity levels. Exercises 4, 5, 6. (SHACL-SPARQL from Ch. 7 gets a two-minute mention, not a demo.)
Free practice & wrap-up. The Capstone exercise: bring your own domain, design shapes, read validation reports. This is where SHACL becomes real. Closes with Q&A and pointers for post-course reading.
Running long? Ch. 6 always eats time. If the morning constraints block overruns, drop Exercise 3 and give the ten minutes back to the afternoon. The engine block (Exercise 6) is the one not to squeeze.
Pick a block below to start. Each block has exercises, a shapes editor and pre-loaded data to validate your answers against.
Your first shape — node shapes, target classes, property paths, cardinality and datatype.
Value range, string patterns, the Turtle-escaping gotcha for sh:pattern.
Logical constraints (sh:or, sh:xone) and closed shapes.
Read a validation report: focus nodes, result paths, constraint components, severity.
Combine four or more constraint categories in one shape — or bring your own domain.
Test your knowledge of the full SHACL curriculum. Score 80% or higher to earn your completion badge. Choose the best answer for each question.
∈ mean?∈ denotes set membership — it reads "a is an element of B". Subset uses ⊆, intersection uses ∩.ex:Solaris ex:author ex:Lem ., what role does ex:author play?ex:author sits in the middle, making it the predicate (the relationship between subject and object).;) do?,) adds another object sharing the same subject and predicate. The dot (.) terminates a statement.ex:author rdfs:range ex:Person and ex:Hobbit ex:author ex:Tolkien, what does a reasoner infer?rdfs:range means the object of the property is inferred to be of the given type. So the reasoner infers ex:Tolkien a ex:Person. Domain/range is for inference, not validation.sh:path, which specifies which property it constrains. Node shapes target focus nodes directly and do not use sh:path.ex:author predicate?sh:targetSubjectsOf selects all nodes that appear as the subject of triples with the given predicate. sh:targetObjectsOf would select the objects instead.sh:path ( ex:author ex:name ) represent?sh:path defines a sequence path. It follows each step in order: starting from the focus node, follow ex:author, then from that node follow ex:name.sh:minCount 1 and sh:maxCount 1 on ex:mainTitle. A book has two titles. What happens?sh:maxCount 1 is set produces a sh:MaxCountConstraintComponent violation. SHACL constraints are strict — there is no "suggestion" mode.sh:nodeKind sh:IRI constrains the node kind to be an IRI. sh:class checks rdf:type, and sh:datatype checks literal datatypes — neither checks for IRI vs literal directly.ex:birthDate and a ex:birthYear. Does this conform to sh:xone applied to shapes requiring each?sh:xone (exclusive or) requires that exactly one of the listed shapes conforms. If both conform, it is a violation. sh:or allows one or more to conform.sh:closed true and sh:ignoredProperties ( rdf:type ), with one property shape for ex:mainTitle. A node has rdf:type, ex:mainTitle, and ex:author. Does it conform?sh:closed true means only properties declared in the shape (via sh:property) or listed in sh:ignoredProperties are allowed. ex:author is neither, so it violates.sh:disjoint ex:editor on a property shape for ex:author enforce?sh:disjoint ensures the set of values for the constrained property shares no elements with the set of values for the referenced property. If the same person appears as both author and editor, it is a violation.$this represent?$this is a pre-bound variable that refers to the current focus node being validated. On a property shape, $PATH refers to the property path.sh:focusNode identifies the node being validated that caused the result. sh:value is the specific value that failed, sh:resultPath is the property, and sh:sourceShape is the shape that defined the constraint.You scored — you need at least 80% (16/20) to earn the badge. Review the explanations above and try again!