Semantic Layer course
Knowledge layer 30 min AccuracyConsistencyExplainability

Constraints with SHACL

OWL will not tell you the KYC document is missing

Section 1

The application that should have been stopped

Next section
Section 2

Open world and closed world

Next section
Section 3

Writing shapes

Next section
Section 4

Severity, messages, and the applicant shape

Next section
Section 5

Which one complains?

Next section
Section 6

The validation report is your audit trail

Next section
Section 7

Three places validation runs

Hands on

Catch the bad loan data

25 min

Write shapes.ttl, run pySHACL against the Meridian graph, get violations for Tobias's missing KYC document and an out-of-range credit score, then fix the data and get sh:conforms true.

make lab-up            # once, starts Postgres + Fuseki + Ontop
make lab lab06-shacl-gate

Full instructions, starter files and the solution are in labs/modules/lab06-shacl-gate/README.md. The lab checks its own work, so you will know if it passed.

Check yourself

Quiz

7 questions, pass mark 70%. Answers are explained either way, so a wrong guess is not wasted.

1 Application APP-9002 has no KYC document linked. An OWL reasoner reports the graph is consistent. Why?
2 Which two are true about the difference between owl:minCardinality 1 and sh:minCount 1 on the same property? (pick two)

Select all that apply.

3 You need a rule saying a loan with a write-off date must have days past due of 90 or more. Why does this need sh:sparql rather than core SHACL constraints?
4 Meridian marks a missing or non-positive annual income as sh:Warning rather than sh:Violation. What is the reasoning?
5 Which field of a SHACL validation result tells you which specific constraint rule fired?
6 Why does Meridian run SHACL validation on the asserted graph before running the reasoner, rather than after?
7 In the LoanApplicationShape, why is the KYC requirement written with sh:qualifiedValueShape and sh:qualifiedMinCount 1 instead of a plain sh:minCount 1 on mrb:evidencedBy?