Semantic Layer course
Knowledge layer 35 min AccuracyConsistencyExplainability

Asking questions with SPARQL

Draw the shape you are looking for and let the graph fill it in

Section 1

Matching a shape, not joining tables

Next section
Section 2

Watching patterns bind

Next section
Section 3

OPTIONAL, UNION, and the cost of getting them backwards

Next section
Section 4

Aggregates and the four query forms

Next section
Section 5

Property paths, and the query SQL hates

Next section
Section 6

Closing the Tuesday loop

Hands on

Answer the CRO's question three ways

30 min

Run all three default definitions as SPARQL against Fuseki and reproduce the counts 1,847, 4,102 and 1,203 from one unchanged graph.

make lab-up            # once, starts Postgres + Fuseki + Ontop
make lab lab04-sparql-drills

Full instructions, starter files and the solution are in labs/modules/lab04-sparql-drills/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 How does a SPARQL WHERE block differ from a SQL FROM and JOIN clause?
2 You query all loans and their collateral without OPTIONAL. What happens to Daniel's unsecured loan L-2087?
3 Which two query forms would you use for these jobs: deciding whether one specific loan meets a rule, and writing inference results back into the graph? (pick two)

Select all that apply.

4 In SPARQL, what does mrb:relatedParty+ mean?
5 Meridian's Finance definition of default counts 1,203 loans where Risk counts 1,847. In the Finance SPARQL query, what produces that difference?
6 You write COUNT(?collateral) where ?collateral is bound inside an OPTIONAL block, intending to count loans per branch. What do you get?
7 What is the SERVICE keyword for?