Skip to main content

SPARQL Protocol and RDF Query Language (SPARQL)

SPARQL Protocol and RDF Query Language (SPARQL) is a query language that allows you to query triplestores. It translates graph data into normalized, tabular data with rows and columns. It is useful to think of a SPARQL query as a Mad Lib—a set of sentences with blanks in them. The database will take this query and find every set of matching statements that correctly fill in those blanks. What makes SPARQL powerful is the ability to create complex queries that reference many variables at a time.

Examples

  SELECT ?painting
WHERE {
?painting <has medium> <oil on canvas> .
}
  • The following query has a second variable: ?artist. The database will return all matching combinations of ?artist and ?painting that fulfill both of these statements.
     SELECT ?artist ?painting
WHERE {
?artist <has nationality> <Dutch> .
?painting <was created by> ?artist .
}
  • CWRC Linked Data (2022) “CWRC SPARQL Endpoint”: The SPARQL query at the above link returns all of the people in CWRC’s current LODset (currently the first extraction from Orlando’s dataset on British women’s writing) who were born in the nineteenth century, ordered by birthdate.

Further Resources