querying linked data with sparql and the wikidata query
play

Querying Linked Data with SPARQL and the Wikidata Query Service - PowerPoint PPT Presentation

Querying Linked Data with SPARQL and the Wikidata Query Service Lucas Werkmeister 2019-12-27 Lucas Werkmeister https://tinyurl.com/36c3-wdqs 1/20 An example graph happens in is next to Esszimmer is next to Kche is part of happens in


  1. Querying Linked Data with SPARQL and the Wikidata Query Service Lucas Werkmeister 2019-12-27 Lucas Werkmeister https://tinyurl.com/36c3-wdqs 1/20

  2. An example graph happens in is next to Esszimmer is next to Küche is part of happens in is part of is followed by live querying WikipakaWG this talk follows starts at is part of 2019-12-27T 36C3 12:00:00+0100 is part of starts at happens in is part of Chaos-West Klimawahlen Chaos West Stage Lucas Werkmeister https://tinyurl.com/36c3-wdqs 2/20

  3. Example questions Which talk follows this one? this talk ?talk follows Matching triple: live querying this talk follows Lucas Werkmeister https://tinyurl.com/36c3-wdqs 3/20

  4. Example questions Same question, phrased differently: Which talk is this one followed by? This talk is followed by which one? is followed by this talk ?talk Matching triple: is followed by live querying this talk Lucas Werkmeister https://tinyurl.com/36c3-wdqs 4/20

  5. Example questions Which talk happens in Esszimmer? Esszimmer happens in ?talk Matching triples: happens in Esszimmer happens in live querying this talk Lucas Werkmeister https://tinyurl.com/36c3-wdqs 5/20

  6. Example questions Which talks happen in the WikipakaWG? That is, which talks happen in a room that’s part of the WikipakaWG? ?room is part of happens in WikipakaWG ?talk Matching triples: happens in Esszimmer is part of happens in live querying WikipakaWG this talk Lucas Werkmeister https://tinyurl.com/36c3-wdqs 6/20

  7. SPARQL Esszimmer happens in ?talk might translate into: SELECT * WHERE { ?talk 36c3:happensIn 36c3:Esszimmer. } The 36c3: prefix clarifies which Esszimmer we’re talking about. Lucas Werkmeister https://tinyurl.com/36c3-wdqs 7/20

  8. SPARQL ?room is part of happens in WikipakaWG ?talk might translate into: SELECT * WHERE { ?talk 36c3:happensIn ?room. ?room 36c3:isPartOf 36c3:WikipakaWG. } Lucas Werkmeister https://tinyurl.com/36c3-wdqs 8/20

  9. SPARQL ?room is part of happens in WikipakaWG ?talk might also translate into: SELECT ?talk WHERE { ?talk 36c3:happensIn [ schema:isPartOf 36c3:WikipakaWG ]. } Lucas Werkmeister https://tinyurl.com/36c3-wdqs 9/20

  10. Example queries Which software is written in Bash? Lucas Werkmeister https://tinyurl.com/36c3-wdqs 10/20

  11. Example queries Which software is written in Bash? programming language ?software Bash Lucas Werkmeister https://tinyurl.com/36c3-wdqs 10/20

  12. Example queries Which software is written in Bash? programming language ?software Bash SELECT ?software WHERE { ?software wdt:P277 wd:Q189248. } Lucas Werkmeister https://tinyurl.com/36c3-wdqs 10/20

  13. Example queries Who was born at sea? Lucas Werkmeister https://tinyurl.com/36c3-wdqs 11/20

  14. Example queries Who was born at sea? place of birth ?person at sea Lucas Werkmeister https://tinyurl.com/36c3-wdqs 11/20

  15. Example queries Who was born at sea? place of birth ?person at sea SELECT ?person WHERE { ?person wdt:P19 wd:Q55438959. } Lucas Werkmeister https://tinyurl.com/36c3-wdqs 11/20

  16. Example queries Which places are located on the White Elster? Lucas Werkmeister https://tinyurl.com/36c3-wdqs 12/20

  17. Example queries Which places are located on the White Elster? located in or next to body of water ?place White Elster Lucas Werkmeister https://tinyurl.com/36c3-wdqs 12/20

  18. Example queries Which places are located on the White Elster? located in or next to body of water ?place White Elster SELECT ?place WHERE { ?place wdt:P206 wd:Q44729. } Lucas Werkmeister https://tinyurl.com/36c3-wdqs 12/20

  19. Example queries Where does The Neverending Story take place? Lucas Werkmeister https://tinyurl.com/36c3-wdqs 13/20

  20. Example queries Where does The Neverending Story take place? narrative location The Neverending Story ?place Lucas Werkmeister https://tinyurl.com/36c3-wdqs 13/20

  21. Example queries Where does The Neverending Story take place? narrative location The Neverending Story ?place SELECT ?place WHERE { wd:Q463108 wdt:P840 ?place. } Lucas Werkmeister https://tinyurl.com/36c3-wdqs 13/20

  22. Example queries Which popes had children? Lucas Werkmeister https://tinyurl.com/36c3-wdqs 14/20

  23. Example queries Which popes had children? position held father pope ?pope ?child Lucas Werkmeister https://tinyurl.com/36c3-wdqs 14/20

  24. Example queries Which popes had children? position held father pope ?pope ?child SELECT ?pope ?child WHERE { ?child wdt:P22 ?pope. ?pope wdt:P39 wd:Q19546. } Lucas Werkmeister https://tinyurl.com/36c3-wdqs 14/20

  25. Example queries Which popes had children? Lucas Werkmeister https://tinyurl.com/36c3-wdqs 15/20

  26. Example queries Which popes had children? pope position held ?pope child ?child Lucas Werkmeister https://tinyurl.com/36c3-wdqs 15/20

  27. Example queries Which popes had children? pope position held ?pope child ?child SELECT ?pope ?child WHERE { ?pope wdt:P39 wd:Q19546; wdt:P40 ?child. } Lucas Werkmeister https://tinyurl.com/36c3-wdqs 15/20

  28. Example queries Which Microsoft software runs on Linux? Lucas Werkmeister https://tinyurl.com/36c3-wdqs 16/20

  29. Example queries Which Microsoft software runs on Linux? Microsoft developer ?software operating system Linux Lucas Werkmeister https://tinyurl.com/36c3-wdqs 16/20

  30. Example queries Which Microsoft software runs on Linux? Microsoft developer ?software operating system Linux SELECT ?software WHERE { ?software wdt:P178 wd:Q2283; wdt:P306 wd:Q388. } Lucas Werkmeister https://tinyurl.com/36c3-wdqs 16/20

  31. Example queries What are some compositions for organ and orchestra? Lucas Werkmeister https://tinyurl.com/36c3-wdqs 17/20

  32. Example queries What are some compositions for organ and orchestra? organ instrumentation ?composition instrumentation orchestra Lucas Werkmeister https://tinyurl.com/36c3-wdqs 17/20

  33. Example queries What are some compositions for organ and orchestra? organ instrumentation ?composition instrumentation orchestra SELECT ?composition WHERE { ?composition wdt:P870 wd:Q1444, wd:Q42998. } Lucas Werkmeister https://tinyurl.com/36c3-wdqs 17/20

  34. Example queries Which Nazi party members later received the Order of Merit of the Federal Republic of Germany? Lucas Werkmeister https://tinyurl.com/36c3-wdqs 18/20

  35. Example queries Which Nazi party members later received the Order of Merit of the Federal Republic of Germany? NSDAP member of political party instance of ?person human award received Bundesverdienstkreuz Lucas Werkmeister https://tinyurl.com/36c3-wdqs 18/20

  36. Example queries Which Nazi party members later received the Order of Merit of the Federal Republic of Germany? NSDAP member of political party instance of ?person human award received Bundesverdienstkreuz SELECT ?person WHERE { ?person wdt:P31 wd:Q5; wdt:P102 wd:Q7320; wdt:P166 wd:Q21164. } Lucas Werkmeister https://tinyurl.com/36c3-wdqs 18/20

  37. Example queries What are the largest cities (by population) with a female mayor? Lucas Werkmeister https://tinyurl.com/36c3-wdqs 19/20

  38. Example queries What are the largest cities (by population) with a female mayor? city instance of population ?city ?population human instance of head of government gender ?mayor ?female (Not pictured: the “largest” part.) Lucas Werkmeister https://tinyurl.com/36c3-wdqs 19/20

  39. Example queries What are the largest cities (by population) with a female mayor? SELECT ?city ?mayor ?population WHERE { ?city wdt:P31 wd:Q515; wdt:P1082 ?population; wdt:P6 ?mayor. ?mayor wdt:P31 wd:Q5; wdt:P21 wd:Q6581072. } ORDER BY DESC(?population) LIMIT 10 (Note that this misses some items that are e. g. “instance of: big city” rather than “instance of: city”.) Lucas Werkmeister https://tinyurl.com/36c3-wdqs 19/20

  40. Example queries What are the largest cities (by population) with a female mayor? SELECT ?city WHERE { ?city wdt:P31 wd:Q515; wdt:P1082 ?population; wdt:P6 [ wdt:P31 wd:Q5; wdt:P21 wd:Q6581072 ]. } ORDER BY DESC(?population) LIMIT 10 Lucas Werkmeister https://tinyurl.com/36c3-wdqs 19/20

  41. Closing stuff Fun/interesting queries: @WikidataFacts or @WikidataFacts@mastodon.social Wikidata Query Service help portal: wikidata:Help:SPARQL (w.wiki/EV2) Many many example queries: wikidata:Wikidata:SPARQL query service/queries/examples (w.wiki/EXA) These slides: github.com/lucaswerkmeister/36c3-wdqs Other queries promised in the talk description: Which films starred more than one future head of government? (w.wiki/EV$) When did women finally outnumber Johns in the House of Commons? (w.wiki/EVz) Lucas Werkmeister https://tinyurl.com/36c3-wdqs 20/20

Recommend


More recommend