Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

SPARQL and Jupyter Notebooks

Training
Hands-on sessions on writing SPARQL on Amazon Neptune Jupyter Notebooks using the Northwind
sample RDF Graph Database.

Share this word document.

Training Resources and References

1. Semantic Knowledge Graph and SPARQL Training


Knowledge Graphs - Foundations and Applications | openHPI

2. EKGF
Home | Enterprise Knowledge Graph Foundation (ekgf.org)

3. Medium Articles

- Northwind SQL vs SPARQL


This demo allows hands-on experience on Knowledge Graph databases by executing
SPARQL queries side-by-side with their SQL counterparts.
https://medium.com/gitconnected/northwind-sql-vs-sparql-de662f2e0e7b
Note the difference in amount of code needed to emulate the property path in SQL!

- Northwind Use Case on Amazon Neptune


EGKF Guiding Principles - Use Case Template – Deployed on BT staging environment
https://medium.com/@mbarbieri77/northwind-use-case-on-amazon-neptune-
0e85378307a7

Jupyter Notebooks at BT

1. Northwind
For everyone who has been working with Jupyter Notebooks, SPARQ, RDF and EKGF guiding
principles (Use cases and Stories), we have deployed a Jupyter Notebook implementation of
the Northwind Use Case in the location below.
northwind-use-case - Jupyter Notebook (sagemaker.aws)
TODO: Check if everybody has access to this notebook and can execute stories.
2. Studio Data Exploration Notebook
Walk-through
IMPORTANT: don’t run the heavy stories, e.g. count triple in named graphs, etc.

3. Studio Use Case Notebook


Walk-through

Notebooks  Source Code  API Call  UI

Execute Story in Jupyter Notebooks:


As a Knowledge Graph Engineer, I want to see all Personas

Show the story implementation in the code base:


use-case/studio/stories/get-personas (sparql and ttl)

API call to story get-personas:


Each story will be made available through the story service API, as per example below.
https://dev.dt.cds.bt.com/api/story/studio/get-personas/

Demonstrate the UI:


GenTwin Studio - GenTwin (bt.com)
Digital Twin/Business Support/Data Management/Studio and choose Stories from the
menu list on the left hand side.

4. GDPR, T-500 and CDMC Transformations and Stories


Walk-through
Refer to “Other Topics”, GDPR Excel macro.

5. Create the Northwind Training Notebook

a. Show Training directory on Jupyter Notebooks and share location


Home (sagemaker.aws)

b. Create training notebook with unique name, e.g. northwind-sparql-training-<name>-


<surname>

c. Show Northwind N-TRIPLE file in the repo (northwind-dataset.nt)

i. Chose an Order and show rdf:type


ii. Explain RDF and concept of triples
iii. IRI (EKGF Identity)
iv. Data types
v. Show Order class in the end of the file
vi. Search by the Customer of the Order (same customer placed other orders
and have other properties)

d. Create first basic query with no prefixes


IMPORTANT: Don’t forget to add LIMIT to it.

e. Copy an Order from N-TRIPLE file to the Subject position of the query

f. Show rdfs:Class in the end of N-TRIPLE file


Discuss RDF, RDFS, OWL.

g. Replace predicate with rdf:type

h. Replace predicate with “a”

i. Get the type IRI and replace the Object to display all orders

j. Add GRAPH block

k. Copy GRAPH IRI and replace variable ?g


DISCUSSION: Dataset management, performance, refresh external datasets,
named graphs in Neptune and other triplestores + article on Named Graphs.

l. Query triple { ?s a rdfs:Class } inside the Northwind GRAPH to get a list of Classes
<s3://bt-dt-dev-metadata/static-dataset/northwind/northwind-dataset.nt>

m. Start writing the Northwind Use Case Stories (SPARQL) one by one

Future Training Sessions

1. Export data from relational, CSV or Excel to triples


a. Show GDPR macro in excel
b. Explain how to transform tabular to RDF
c. Show N-TRIPLES in the GDPR transform notebook

2. Ontology and Reasoning


a. Sub Classes and Properties
b. Datatype and Object Property (RDFS vs OWL)
c. Property Chains (PropertyChainAxiom)
d. Transitive Properties
e. SameAs
f. Inverse Properties
g. Symmetric Properties
h. Disjoint
i. InverseOf
j. Functional Property (exact 1) e.g. Status
k. Cardinality (on property – in Protégé accessible via Class)

3. AI Assistants to write RDF tests and SPARQL


a. IDE with AI assistant
b. Copilot
c. CDMC example from Clion AI Assistant

Further Resources and Articles

Graph Exploration and Visualization


https://medium.com/gitconnected/exploring-a-rdf-graph-database-ba2688f9e118

Named Graphs
https://medium.com/gitconnected/working-with-rdf-database-named-graphs-a5ddab447e91

Reasoning
https://medium.com/gitconnected/reasoning-with-northwind-16cf3edf3a67

Benchmarking
https://medium.com/gitconnected/the-semantic-graph-database-benchmark-problem-
2aa6a44c5940

SPARQL 1.2 Proposals


https://medium.com/gitconnected/sql-features-not-supported-in-sparql-1-1-eb34e3519077

You might also like