query language SPARQL (pronounced “sparkle”)
SPARQL in an SQL -like query language for RDF data, spesified by the RDF Data Acess working group of W3C. it differs from SQL in the following aspects:
- SPARQL does not contain spesific Data Definition Language (DLL) provisions because the schemas are represented in both RDFS and OWL as standard RDF graphs, thus requiring no specific language to deal with them.
- SPARQL is not a Data Modification Language (DML), that is, one cannot insert, delete and update RDF graphs using SPARQL. the major reason for this is that there is still no consensus on the optimal DML design for RDF.
SPARQL support four types of queries:
- SELECT queries – return n-tuples of results just like the SELECT queries in SQL
- DESCRIBE queries – return an RDF graph. the resulting graph describe the resource, which match the query contraints. Usually, a description of a resource is considered an RDF-molocule, forming the immediate neighborhood of an URI.
- ASK queries- provide positive or negative answer indicating whether or not the query pattern can be satisfied.
- CONSTRUCT queries – return an RDF graph constructed by means of the substitution of the variables in the graph template and combining the triples into a single RDF graph by set union.
named graph, is an RDf graph with assigned name in the form of a URI reference. in an extended RDF model, one can deal with multiple named graphs and describe the graphs, making statement about them, putting their URIs in subject position. while the original definition of named graphs leaves plenty of room for interpretation, a more concrete definition is provided in the specification of SPARQL.
a SPARQL query is composedof five parts zero or more prefix declarations, a query result clause, zero or more FROM or FROM NAMED clauses, a WHERE clause, and zero or more query modifiers. the optional PREFIX declarations introduce shorcuts for long IRIs as normally done when working with XML namespace. such prefixes can be used in the WHERE clause.
a SPARQL query can take four forms: SELECT, ASK, CONSTRUCT and DESCRIBE.
The WHERE clause is the core of a SPARQL query. It is specified in terms of a set of triple
patterns. As extensively explained in the following sections, these triple patterns are used
to select the triples composing the result.