1 / 40

RDF and SPARQL

RDF and SPARQL. Madalina Croitoru. Representing Knowledge. What type of knowledge. Novels and short stories are books A book is a document Every book has an author A document has a title A title is a String Hugo is the author of Notre Dame de Paris. How to represent this using:.

Télécharger la présentation

RDF and SPARQL

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. RDF and SPARQL MadalinaCroitoru

  2. Representing Knowledge

  3. What type of knowledge • Novels and short stories are books • A book is a document • Every book has an author • A document has a title • A title is a String • Hugo is the author of Notre Dame de Paris

  4. How to represent this using: • Conceptual Graphs • Database Model • RDF(S)

  5. Generally speaking {p(x, y), q(y, z, t), p(z, A), q(z, t, B)} Facts: Conjunction of positive atoms

  6. Generally speaking Facts: Conjunction of positive atoms {p(x, y), q(y, z, t), p(z, A), q(z, t, B)} x 1 p 2 y A B 1 q 3 p t 2 z q

  7. Conceptual Graphs - Databases

  8. Conceptual Graphs - Databases RDF(S)???

  9. Representing Knowledge • Conceptual Graphs • Database Model • RDF(S) • OWL 2… • …

  10. What good to representknowledge? • Querying! • What type of queries? • Conjunctive queries • Ontological queries

  11. Ontological Conjuctive Query Answering Facts Conjunctive Query ╞ Facts: Conjunction of positive atoms Ontology Query: Conjunction of positive atoms

  12. Ontological Conjuctive Query Answering Facts Conjunctive Query ╞ Ontology Φ

  13. Facts ╞ Conjunctive Query Simple RDF entailment Database Conjunctive Query Answering Deduction in the conjunctive, positive, existential fragment of FOL

  14. Ontological Conjuctive Query Answering Facts Conjunctive Query ╞ Ontology Type Hierarchy Every cat is a vertebrate If two people are brothers then they are relatives

  15. Facts + Type Hierarchy ╞ Conjunctive Query RDF(S) entailment Conjunctive Positive Fragment of FOL Simple Conceptual Graphs Entailment

  16. Ontological Conjuctive Query Answering Facts Conjunctive Query ╞ Ontology Rules For every cat there exists a cat who is its mother

  17. Facts + Rules╞ Conjunctive Query Simple Conceptual Graphs Rules DATALOG +

  18. Conjunction of positive atoms • Conceptual Graphs • Database Model • RDF(S)

  19. Conjunction of positive atoms • Conceptual Graphs • Database Model • RDF(S) HOW TO QUERY THIS KNOWLEDGE?!?

  20. Conjunction of positive atoms • Conceptual Graphs – projection (labelled graph homomorphism) • Database Model • RDF(S) HOW TO QUERY THIS KNOWLEDGE?

  21. Conjunction of positive atoms • Conceptual Graphs • Database Model - SQL • RDF(S) HOW TO QUERY THIS KNOWLEDGE

  22. Conjunction of positive atoms • Conceptual Graphs • Database Model • RDF(S) - SPARQL HOW TO QUERY THIS KNOWLEDGE

  23. Codd’s Relational Model

  24. Codd’s Relational Model

  25. RDF

  26. RDF The "http://en.wikipedia.org/wiki/Tony_Benn", published by Wikipedia, has for title 'Tony Benn‘ <http://en.wikipedia.org/wiki/Tony_Benn> <http://purl.org/dc/elements/1.1/publisher> "Wikipedia" <http://en.wikipedia.org/wiki/Tony_Benn> <http://purl.org/dc/elements/1.1/title> "Tony Benn" .

  27. RDF The "http://en.wikipedia.org/wiki/Tony_Benn", published by Wikipedia, has for title 'Tony Benn‘. <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/"> <rdf:Descriptionrdf:about="http://en.wikipedia.org/wiki/Tony_Benn"> <dc:title>Tony Benn</dc:title> <dc:publisher>Wikipedia</dc:publisher> </rdf:Description> </rdf:RDF>

  28. SQL for Databases • SELECT: • FROM (tables) • WHERE (predicate) • GROUP BY (rows) • HAVING (predicate on GROUP BY rows) • ORDER BY (columns)

  29. Select Clause example SELECT * FROM Book WHERE price > 100.00 ORDER BY title;

  30. SPARQL SELECT ?name ?email WHERE { ?person rdf:type foaf:Person. ?person foaf:name ?name. ?person foaf:mbox ?email. }

  31. SPARQL PREFIX foaf: <http://xmlns.com/foaf/0.1/> SELECT ?name ?email WHERE { ?person rdf:type foaf:Person. ?person foaf:name ?name. ?person foaf:mbox ?email. }

  32. SPARQL – example 1 Data: <http://example.org/book/book1> <http://purl.org/dc/elements/1.1/title> "SPARQL Tutorial" . Query: SELECT ?title WHERE { <http://example.org/book/book1> <http://purl.org/dc/elements/1.1/title> ?title . }

  33. SPARQL – example 2 Data: @prefix foaf: <http://xmlns.com/foaf/0.1/> . _:a foaf:name "Johnny Lee Outlaw" . _:a foaf:mbox <mailto:jlow@example.com> . _:b foaf:name "Peter Goodguy" . _:b foaf:mbox <mailto:peter@example.org> . _:c foaf:mbox <mailto:carol@example.org> .

  34. SPARQL – example 2 Query: PREFIX foaf: <http://xmlns.com/foaf/0.1/> SELECT ?name ?mbox WHERE { ?x foaf:name ?name . ?x foaf:mbox ?mbox }

  35. SPARQL – example 2 Result: namembox "Johnny Lee Outlaw“ <mailto:jlow@example.com> "Peter Goodguy" <mailto:peter@example.org>

  36. Construct in SPARQL Data: @prefix org: <http://example.com/ns#> . _:a org:employeeName "Alice" . _:a org:employeeId 12345 . _:b org:employeeName "Bob" . _:b org:employeeId 67890 .

  37. Construct in SPARQL Query: PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX org: <http://example.com/ns#> CONSTRUCT { ?x foaf:name ?name } WHERE { ?x org:employeeName ?name }

  38. Construct in SPARQL Result: @prefix org: <http://example.com/ns#> . _:x foaf:name "Alice" . _:y foaf:name "Bob" .

  39. Construct in SPARQL Result Serialized: <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:foaf="http://xmlns.com/foaf/0.1/" > <rdf:Description> <foaf:name>Alice</foaf:name> </rdf:Description> <rdf:Description> <foaf:name>Bob</foaf:name> </rdf:Description> </rdf:RDF>

  40. SPARQL exercise • Use both SELECT and CONSTRUCT • What are all the country capitals of Africa?

More Related