Chapter 5. SPARQL—querying the Linked Data Web
This chapter covers
- An introduction to the SPARQL query language for RDF
- Sample SPARQL queries
- An overview of SPARQL query types
- SPARQL results formats
Every database needs a query language. SPARQL is to RDF data as SQL is to a relational database. SPARQL is the query language for structured data on the Web, specifically data accessible in RDF formats or representable as such. SPARQL is therefore the query language for Linked Data. The primary purpose of SPARQL is to provide a formal language in which meaningful questions can be phrased.
This chapter discusses how to query the Web of Data as if it were a database—a big, highly distributed database on the internet. A query language for the Web of Data needs to be able to query files containing RDF data, RDF files accessible on the Web, local databases, and databases exposed to the Web. Further, it needs to be able to query multiple data sources at once and thus be able to dynamically build a large, virtual RDF graph from those multiple data sources. SPARQL is best used when you want to query RDF graphs, as if one or more (possibly distributed) RDF graphs formed a database. We’re going to show you how you can do just that.