This session will be about querying data in RDF, using the SPARQL query language. It starts with observing existing queries in order to understand the constructs of SPARQL queries, then follows with questions to be answered by writing a SPARQL query to a deployed endpoint. Create a text file named <yourfirstname-yourlastname.txt>
where you will copy your answers to the questions and the queries you write, and send it at the end of the session. Do not send me the results of the queries.
In this part, you simply observe the existing examples from Wikidata Query Service.
SERVICE
clause here uses special features of Wikidata that are not available in standard SPARQL endpoints. To execute the query, click on the blue button with a white triangle on the left side.wdt:P31
. What do you read? Do the same for wd:Q146
. Write your answers in the file.Q146
and place your cursor after wd:
. Type Ctrl+Space. Then you should have a little popup that says "Type to search for an entity". Type "cow" and select the entity that corresponds to a kind of cattle and press enter. What is the Q number of this entity? Write your answer in the file.#defaultView:ImageGrid
. This turns any URL of pictures in the result of a query into a displayed image.#defaultView:Map
. Execute the query and see what happens. Then delete the comment and execute again. What allows Wikidata to determine the location of a result? Write your answer in the file.FILTER
, BOUND
, comparators, operators, DATATYPE
, BIND ... AS
, LANG
.We will write query on Wikidata query Service.
SELECT * WHERE {?x rdfs:label "Saint-Étienne"@fr .}
will give you results that identify entities named "Saint-Étienne" in French. Which result corresponds to the French city? Write the full IRI that identifies the city of Saint-Étienne. What are the other results about?rdf:type
but has a property wdt:P31
(instance of) that more or less plays this role. Write a SPARQL query to find the types of Saint-Étienne. Among the types, you should find wd:Q484170
. This corresponds to the "communes in France", the administrative geographic area associated with a city, town or village in France.rdfs:subClassOf
but has something similar: wdt:P279
(subclass of). If we use a property path wdt:P31/wdt:P279*
, we can get all of the types and supertypes. How many types does Saint-Étienne has in Wikidata? Write the query and your answer in the file.wdt:
using Ctrl+Space). You can also find it by looking at a well known city in Wikidata, e.g., Saint-Étienne). Write your query in the file.You may try to find who are the Physics Nobel prize laureates from Europe.
You may also try to find who are the widow of assassinated USA presidents. Then of all presidents, regardless of the country.