From property graphs to knowledge graphs
PhD Defense - Julian BRUYAT - 2024-06-03
1
Jury
Property graphs and RDF graphs: Knowledge graphs
2/39
Property graphs and RDF graphs: Property graphs
3/39
:Person
name: Tintin
job: Reporter
:Person
name: Haddock
:Animal
name: Snowy
:owns
:travelsWith
since: The crab with the golden claws
Vendors: Neo4j, JanusGraph, Amazon Neptune, Azure Cosmos DB…
Running example as a property graph
Property graphs and RDF graphs: Property graphs
4/39
Screenshot of the user interface of Neo4j
Property graphs and RDF graphs: RDF graphs
5/39
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix ex: <http://www.example.org/> .
@prefix dbpedia: <http://dbpedia.org/resource/> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix schema: <http://schema.org/> .
_:tintin rdf:type foaf:Person .
_:tintin foaf:name "Tintin" .
_:tintin schema:job dbpedia:Reporter .
dbpedia:Reporter schema:name "Reporter" .
_:snowy rdf:type dbpedia:Animal .
_:snowy dbpedia:name "Snowy" .
_:haddock rdf:type foaf:Person .
_:haddock foaf:name "Haddock" .
_:tintin ex:owns _:snowy .
_:travelers� ex:traveler _:tintin� ex:traveler _:haddock
ex:since "The crab with the golden claws" .
Running example as an RDF graph written in Turtle
Running example as an RDF graph in a graphical representation
Property graphs and RDF graphs: RDF-star graphs
6/39
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix ex: <http://www.example.org/> .
@prefix dbpedia: <http://dbpedia.org/resource/> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix schema: <http://schema.org/> .
_:tintin rdf:type foaf:Person .
_:tintin foaf:name "Tintin" .
_:tintin schema:job dbpedia:Reporter .
dbpedia:Reporter schema:name "Reporter" .
_:snowy rdf:type dbpedia:Animal .
_:snowy dbpedia:name "Snowy" .
_:haddock rdf:type foaf:Person .
_:haddock foaf:name "Haddock" .
_:tintin ex:owns _:snowy .
_:tintin ex:travelsWith _:haddock .
# RDF-star
<< _:tintin ex:travelsWith _:haddock >>
ex:since "The crab with the golden claws".
Running example as an RDF-star graph written in Turtle-star
Running example as an RDF-star graph in a graphical representation
Property graphs and RDF graphs: RDF graphs
7/39
Property graphs and RDF graphs
8/39
| Property Graphs | RDF graphs |
Definition | A graph, depends on vendors | Standardized as a set of RDF triples |
Semantics | Local | Global |
Merging two graphs | It is complicated | U mathematical operator |
Query language | Path traversal:�Gremlin, OpenCypher GQL | Pattern matching:�SPARQL |
Adding information to edges | Native support | RDF-star (RDF 1.2) |
Even though they both rely on a graph data structure, property graphs and RDF graphs are very different
Objectives
9/39
Convert PG data to RDF to benefit from its advantages
in terms of reasoning, data integration, data validation…
conversion
reversibility?
State of the art
10/39
:node1 rdf:type :Person .
:node1 :name "Tintin" .
:node1 :travelsWith :node2 .
<< :node1 :travelsWith :node2 >> :since "The crab …" .
:node2 rdf:type :Person .
Conversion operated by NeoSemantics, a Neo4j plugin for PG - RDF interoperability
:Person
name: Tintin
:Person
:travelsWith
since: The crab with the golden claws
[1] Tomaszuk, D., Angles, R., & Thakkar, H. (2020). Pgo: Describing property graphs in rdf. IEEE Access, 8, 118355-118369.
_:pg pgo:hasNode _:node1 .
_:pg pgo:hasNode _:node2 .
_:pg pgo:hasEdge _:edge3 .
_:node1 rdf:type pgo:Node .
_:node1 pgo:label "Person" .
_:node1 pgo:hasNodeProperty _:property1 .
_:property1 pgo:key "name" .
_:property1 pgo:value "Tintin" .
_:node2 rdf:type pgo:Node .
_:node2 pgo:label "Person" .
_:edge3 rdf:type pgo:Edge .
_:edge3 rdf:startNode _:node1 .
_:edge3 rdf:endNode _:node2 .
_:edge3 pgo:hasEdgeProperty _:property3 .
# ...
State of the art
RDF based approach
RDF-star based approach [2]
11/39
[2] Hartig, O. (2019, September). Foundations to Query Labeled Property Graphs using SPARQL. In SEM4TRA-AMAR@ SEMANTiCS.
[3] Khayatbashi, S., Ferrada, S., & Hartig, O. (2022, June). Converting property graphs to RDF: a preliminary study of the practical impact of different mappings. In Proceedings of the 5th ACM SIGMOD Joint International Workshop on Graph Data Management Experiences & Systems (GRADES) and Network Data Analytics (NDA) (pp. 1-9).
dbpedia:Tintin pgo:label "Person" .
dbpedia:Tintin foaf:name "Tintin" .
dbpedia:Haddock pgo:label "Person" .
dbpedia:Tintin :travelsWith dbpedia:Haddock .
<< dbpedia:Tintin :travelsWith dbpedia:Haddock >>
:since "The crab …" .
dbpedia:Tintin pgo:label "Person" .
dbpedia:Tintin foaf:name "Tintin" .
dbpedia:Haddock pgo:label "Person" .
ex:travelers ex:relation "Travellers" .
ex:travelers ex:traveler dbpedia:Tintin .
ex:travelers ex:traveler dbpedia:Haddock .
ex:travelers ex:since "The crab …"
:Person
name: Tintin
:Person
:travelsWith
since: The crab with the golden claws
State of the art
How to design a mapping language allowing users to produce idiomatic RDF graphs from PGs?
12/39
:Person
name: Tintin
job: Reporter
:Person
name: Haddock
:Animal
name: Snowy
:owns
:travelsWith
since: The crab with the golden claws
_:tintin ex:owns _:snowy .
_:travelers ex:traveler _:tintin .�_:travelers ex:traveler _:haddock .
_:travelers
ex:since "The crab with the golden claws" .
A part of the RDF graph presented earlier
Running example PG
Idiomatic RDF graph = a graph that uses common model structures
Motivation
How to design a mapping language allowing users to produce idiomatic RDF graphs from PGs?
13/39
| Most other work | Hartig’s work |
Reuse existing ontologies | ✘ | ✔ |
Adapt existing modeling patterns | ✘ | ✘ |
Preserve information | ✔ | ✔* |
* Under some conditions
Contributions
14/39
PREC-C & PRSC: https://github.com/BruJu/PREC
Shacled Turtle: https://github.com/BruJu/Shacled-Turtle
PREC-C: Example
15/39
:Person
name: Tintin
job: Reporter
:Person
name: Haddock
:Animal
name: Snowy
:owns
:travelsWith
since: The crab with� the golden claws
Property graph
Produced RDF graph
Context
(pseudo code)
Model edges as
?source ?edgeIRI ?destination��Model properties as� ?holder ?propertyIRI ?value
PREC = Property graph to RDF graph Experimental Converter�PREC-C = PREC-Context
:travelsWith → model it as
?self ex:traveler ?source
?self ex:traveler ?destination
:owns → ex:owns
since → ex:since
job → schema:job
but model it as
?holder ?propertyIRI ?self
?self schema:name ?value
name on a :Person → foaf:name
name → dbpedia:name
:Animal → dbpedia:Animal
:Person → foaf:Person
_:tintin rdf:type :Person .
_:haddock rdf:type :Person .
_:snowy rdf:type :Animal .
_:snowy :name "Snowy" .
_:tintin :name "Tintin" .
_:haddock :name "Haddock" .
_:tintin :job "Reporter" .
<< _:tintin :travelsWith _:haddock >>
:since "The crab with the golden claws" .
_:tintin :owns _:snowy .
_:tintin :travelsWith _:haddock .
_:tintin rdf:type foaf:Person .
_:haddock rdf:type foaf:Person .
_:snowy rdf:type dbpedia:Animal .
_:snowy dbpedia:name "Snowy" .
_:tintin dbpedia:name "Tintin" .
_:haddock dbpedia:name "Haddock" .
_:travelers ex:traveler _:tintin .�_:travelers ex:traveler _:haddock .
_:snowy dbpedia:name "Snowy" .
_:tintin foaf:name "Tintin" .
_:haddock foaf:name "Haddock" .
_:tintin schema:job _:reporter .
_:reporter schema:name "Reporter" .
_:tintin ex:owns _:snowy .
<< _:tintin :travelsWith _:haddock >>
ex:since "The crab with the golden claws" .
_:travelers ex:since "The crab with the golden claws" .
+
→
PREC-C: Contexts are RDF graphs
16/39
:Person → foaf:Person
:Animal → dbpedia:Animal
name → dbpedia:name
name on a :Person → foaf:name
job → schema:job
but model it as
?holder ?propertyIRI ?self
?self schema:name ?value
since → ex:since
:owns → ex:owns
:travelsWith → model it as
?self ex:traveler ?source
?self ex:traveler ?destination
Model properties as� ?holder ?propertyIRI ?propertyValue
Model edges as
?source ?edgeIRI ?destination
In the previous slide
In real life
prec:Properties prec:templatedBy prec:DirectTriples .
prec:Edges prec:templatedBy prec:RDFStarOccurrence .
[] a prec:NodeRule ;
prec:label "Person" ;
prec:nodeLabelIRI foaf:Person .
[] a prec:NodeRule ;
prec:label "Animal" ;
prec:nodeLabelIRI dbpedia:Animal .
[] a prec:PropertyRule ;
prec:propertyKey "name" ;
prec:propertyIRI dbpedia:name .
[] a prec:PropertyRule ;
prec:propertyKey "name" ;
prec:label "Person" ; prec:onKind prec:Node ;
prec:propertyIRI foaf:name .
[] a prec:PropertyRule ;
prec:propertyKey "job" ;
prec:propertyIRI schema:job ;
prec:templatedBy [
prec:produces << pvar:holder pvar:propertyIRI pvar:self >> ;
prec:produces << pvar:self schema:name pvar:value >> ;
] .
[] a prec:PropertyRule ;
prec:propertyKey "since" ;
prec:propertyIRI ex:since .
[] a prec:EdgeRule ;
prec:label "owns" ;
prec:edgeIRI ex:owns .
[] a prec:EdgeRule ;
prec:label "travelsWith" ;
prec:templatedBy [
prec:produces << pvar:self ex:traveler pvar:source >> ;
prec:produces << pvar:self ex:traveler pvar:destination >> ;
] .
Terms used in this example:
prec:Properties
prec:templatedBy
prec:DirectTriples
prec:Edges
prec:RDFStarOccurrence
prec:NodeRule
prec:label
prec:nodeLabelIRI
prec:PropertyRule
prec:propertyKey
prec:propertyIRI
prec:produces
prec:onKind
prec:EdgeRule
prec:edgeIRI
pvar:self
pvar:holder
pvar:propertyIRI
pvar:value
pvar:source
pvar:destination
[] a prec:PropertyRule ;
prec:propertyKey "job" ;
prec:propertyIRI schema:job ;
prec:templatedBy [
prec:produces << pvar:holder pvar:propertyIRI pvar:self >> ;
prec:produces << pvar:self schema:name pvar:value >> ;
] .
PREC-C: Design and issues
17/39
:Person :Animal
name: Enid
race: Werewolf
name on a :Person = foaf:name
name on an :Animal = schema:name
Which one do we pick?
Motivation
How to design a mapping language allowing users to produce idiomatic RDF graphs from PGs?
18/39
| Most other work | Hartig’s work | PREC-C |
Reuse existing ontologies | ✘ | ✔ | ✔ |
Adapt existing modeling patterns | ✘ | ✘ | ✔ |
Preserve information | ✔ | ✔* | ? |
* Under some conditions
Contributions
19
PREC-C & PRSC: https://github.com/BruJu/PREC
Shacled Turtle: https://github.com/BruJu/Shacled-Turtle
PRSC: a schema-based conversion
20/39
:Person
name: Tintin
:Person
name: Tintin
job: Reporter
:Person
name: Haddock
:Animal
name: Snowy
:owns
:travelsWith
since: The crab with� the golden claws
:Person
name:
:Animal
name:
:owns
:travelsWith
since:
Running example PG
Schema
PRSC = Property graph to RDF graph Schema-based Converter
You will struggle to pronounce it until you realize you can pronounce it “presc”
:Person
name:
job:
PRSC: The context rises from the schema
21/39
:Person
name:
:Animal
name:
:owns
:travelsWith
since:
Schema
:PersonRule a prec:PRSCNodeRule ;
prec:label "Person" ;
prec:propertyKey "name" ;
prec:produces
:AnimalRule a prec:PRSCNodeRule ;
prec:label "Animal" ;
prec:propertyKey "name" ;
prec:produces
:OwnsRule a prec:PRSCEdgeRule ;
prec:label "owns" ;
prec:produces�
:TravelsWithRule a prec:PRSCEdgeRule ;
prec:label "travelsWith" ;
prec:propertyKey "since" ;
prec:produces
<< pvar:self rdf:type foaf:Person >> ,
<< pvar:self foaf:name "name"^^prec:valueOf >> .
<< pvar:self rdf:type dbpedia:Animal >> ,
<< pvar:self schema:name "name"^^prec:valueOf >> .
� << pvar:source ex:owns pvar:destination >> .
<< pvar:self ex:traveler pvar:source >> ,
<< pvar:self ex:traveler pvar:destination >> ,
<< pvar:self ex:since "since"^^prec:valueOf >> .
PRSC context
PRSC: The output
22/39
:Person
name: Tintin
:Person
name: Haddock
:Animal
name: Snowy
:owns
:travelsWith
since: The crab with� the golden claws
Running example PG
:PersonRule a prec:PRSCNodeRule ;
prec:label "Person" ;
prec:propertyKey "name" ;
prec:produces
<< pvar:self rdf:type foaf:Person >> ,
<< pvar:self foaf:name "name"^^prec:valueOf >> .
:AnimalRule a prec:PRSCNodeRule ;
prec:label "Animal" ;
prec:propertyKey "name" ;
prec:produces
<< pvar:self rdf:type dbpedia:Animal >> ,
<< pvar:self schema:name "name"^^prec:valueOf >> .
:OwnsRule a prec:PRSCEdgeRule ;
prec:label "owns" ;
prec:produces
<< pvar:source ex:owns pvar:destination >> .
:TravelsWithRule a prec:PRSCEdgeRule ;
prec:label "travelsWith" ;
prec:propertyKey "since" ;
prec:produces
<< pvar:self ex:traveler pvar:source >> ,
<< pvar:self ex:traveler pvar:destination >> ,
<< pvar:self ex:since "since"^^prec:valueOf >> .
_:tintin rdf:type foaf:Person .
_:tintin foaf:name "Tintin" .
_:haddock rdf:type foaf:Person .
_:haddock foaf:name "Haddock" .
_:snowy rdf:type dbpedia:Animal .
_:snowy schema:name "Snowy" .
_:tintin ex:owns _:snowy .
_:travelers ex:traveler _:tintin .
_:travelers ex:traveler _:haddock .
_:travelers ex:since
"The crab with the golden claws" .
PRSC context
Produced RDF graph
PRSC: Reversibility
23/39
Well-behaved
contexts
Reversible contexts
All PRSC contexts
PRSC: Well-behaved contexts - No information loss
24/39
:Person
givenName: Archibald
familyName: Haddock
:PersonRule
prec:produces
<< pvar:self foaf:name "givenName"^^prec:valueOf >> .
✘
_:haddock foaf:name "Archibald" .
:PersonRule
prec:produces
<< pvar:self foaf:name "givenName"^^prec:valueOf >> ,
<< pvar:self foaf:name "familyName"^^prec:valueOf >> .
✘
_:haddock foaf:name "Archibald" .
_:haddock foaf:name "Haddock" .
:PersonRule
prec:produces
<< pvar:self foaf:givenName "givenName"^^prec:valueOf >> ,
<< pvar:self foaf:familyName "familyName"^^prec:valueOf >> .
_:haddock foaf:givenName "Archibald" .
_:haddock foaf:familyName "Haddock" .
✔
PRSC: Well-behaved contexts - Signature template triple
25/39
:Person
name: Tintin
:Animal
name: Snowy
:PersonRule
prec:produces
<< pvar:self foaf:name "name"^^prec:valueOf >> .
:AnimalRule
prec:produces
<< pvar:self foaf:name "name"^^prec:valueOf >> .
✘
_:tintin foaf:name "Tintin" .
_:snowy foaf:name "Snowy" .
:PersonRule
prec:produces� << pvar:self rdf:type foaf:Person >> ,
<< pvar:self foaf:name "name"^^prec:valueOf >> .
:AnimalRule
prec:produces� << pvar:self rdf:type dbpedia:Animal >> ,
<< pvar:self foaf:name "name"^^prec:valueOf >> .
_:tintin rdf:type foaf:Person .
_:tintin foaf:name "Tintin" .
_:snowy rdf:type dbpedia:Animal .
_:snowy foaf:name "Snowy" .
✔
:PersonRule
prec:produces
<< pvar:self foaf:name "name"^^prec:valueOf >> .
:AnimalRule
prec:produces
<< pvar:self schema:name "name"^^prec:valueOf >> .
_:tintin foaf:name "Tintin" .
_:snowy schema:name "Snowy" .
✔
PRSC: Well-behaved contexts - Element provenance
26/39
:Person
name: Tintin
:Person
name: Haddock
:travelsWith
:travelsWith
:TravelsWithRule a prec:PRSCEdgeRule ;
prec:label "travelsWith" ;
prec:produces
<< pvar:source ex:travelsWith pvar:destination >> .
_:tintin ex:travelsWith _:haddock .
“RDF graphs are defined as sets of triples”
✘
:TravelsWithRule a prec:PRSCEdgeRule ;
prec:label "travelsWith" ;
prec:produces
<< pvar:self ex:traveler pvar:source >> ,
<< pvar:self ex:traveler pvar:destination >> .
✔
_:travel1 ex:traveler _:tintin .
_:travel1 ex:traveler _:haddock .
_:travel2 ex:traveler _:tintin .
_:travel2 ex:traveler _:haddock .
PRSC: Reversibility algorithm for well-behaved contexts
27/39
PRSC: Edge-unique types
28/39
:Person
name: Tintin
:Animal
name: Snowy
:owns
:Animal
name: The llama in Prisoners of the sun
PRSC: Edge-unique types
29/39
:Person
name: Tintin
:Animal
name: Snowy
:owns
:Animal
name: The llama in “Prisoners of the sun”
:OwnsEdgeRule a prec:PRSCEdgeRule ;
prec:produces
<< pvar:source ex:owns pvar:destination >> .
_:tintin ex:owns _:snowy .
✔
-> No other template triple is allowed to use ex:owns in predicate position.
PROVED BY THEOREM 7
PRSC: Design and issues
30/39
Motivation
How to design a mapping language allowing users to produce idiomatic RDF graphs from PGs?
31/39
| Most other work | Hartig’s work | PREC-C | PRSC |
Reuse existing ontologies | ✘ | ✔ | ✔ | ✔ |
Adapt existing modeling patterns | ✘ | ✘ | ✔ | ✔ |
Preserve information | ✔ | ✔* | ? | ✔* |
* Under some conditions
Contributions
32/39
PREC-C & PRSC: https://github.com/BruJu/PREC
Shacled Turtle: https://github.com/BruJu/Shacled-Turtle
Shacled Turtle: What do I write in my context?
33/39
Terms used in this presentation:
prec:Properties
prec:templatedBy
prec:DirectTriples
prec:Edges
prec:RDFStarOccurrence
prec:NodeRule
prec:label
prec:nodeLabelIRI
prec:PropertyRule
prec:propertyKey
prec:propertyIRI
prec:onKind
prec:EdgeRule
prec:edgeIRI
pvar:self
pvar:holder
pvar:propertyIRI
pvar:value
pvar:source
pvar:destination
prec:PRSCNodeRule
prec:PRSCEdgeRule
prec:produces
Shacled Turtle: Principle
34/39
Shacled Turtle: How to generate the help?
35/39
Shacled Turtle: Experiments
36/39
Conclusion
37/39
| Most other work | Hartig’s work | PREC-C | PRSC |
Reuse existing ontologies | Uniform conversion | Term mapping | Template graph mapping | |
Adapt existing modeling patterns | Everything uses the same structure | Everything uses the same structure | Depends on the template graph | |
No information loss | Studied most of the time Reversible | Reversible under some conditions | Not studied | Reversible under some conditions |
Design a mapping language allowing users to produce idiomatic RDF graphs from PGs
Conclusion
38/39
| PREC-C | PRSC |
Philosophy | Convert all PGs�Specialized for some nodes, edges and properties | Based on a schema: only convert PGs with the given nodes and edges |
Rules can target | Nodes, edges, properties | Nodes, edges |
Ontology complexity | High (terms, constructs) | Lower |
Expressivity on properties | Meta properties Can introduce a blank node for properties | Restricted |
Information loss | Not studied | Well-behaved context, Edge unique extension |
Design a mapping language allowing users to produce idiomatic RDF graphs from PGs
Perspectives
PREC-C / PRSC
Shacled Turtle
39/39
The characterization function κ
40/39
Well-behaved context: Formal definition
41/39
Shacled Turtle - Architecture
42/39
This slide was not used during the defense
Shacled Turtle - Example
43/39
- The range of founder is ex:Person
- ex:PersonShape targets the ex:Person class
- ex:name is a property of ex:PersonShape shape
This slide was not used during the defense
Substitution predicates
44/39
[] a prec:PropertyRule ;
prec:propertyKey "job" ;
prec:propertyIRI schema:job ;
prec:templatedBy [
prec:produces << pvar:holder pvar:propertyIRI pvar:self >> ;
prec:produces << pvar:self schema:name pvar:value >> ;
] .
prec:propertyIRI a prec:SubstitutionPredicate
prec:substitutionTarget pvar:propertyIRI .
[] a prec:PropertyRule ;
prec:propertyKey "job" ;
prec:substitute [
prec:from pvar:propertyIRI
prec:to schema:job
] ;
prec:templatedBy [
prec:produces << pvar:holder pvar:propertyIRI pvar:self >> ;
prec:produces << pvar:self schema:name pvar:value >> ;
] .
This slide was not used during the defense