SPARQL is a W3C standard. It is a query language for RDF (SPARQL: SPARQL Protocol And RDF Query Language). Please note that OntoBroker only implements a subset of SPARQL (and SPARQL only supports a subset of the ObjectLogic query features). The following table shows how we interpret SPARQL queries in OntoBroker for ObjectLogic ontologies:
Subject |
Predicate |
Object |
ObjectLogic |
Comment |
?S |
rdf:type |
rdfs:Class |
_concepts(?S) |
All classes |
?S |
rdf:type |
rdf:Property |
_properties(?S) |
All properties (i.e. attributes and relations) |
?S |
rdf:type |
?O |
?S:?O AND ... |
Instances (including instances of meta-classes rdfs:Class and rdf:Property) |
?S |
rdfs:subClassOf |
?O |
?S::?O |
Sub-classes |
?S |
rdfs:subPropertyOf |
?O |
?S<<?O |
Sub-properties |
?S |
rdfs:range |
?O |
_PropertyRange(?S,?O) |
RDFS domain (not part of OL) |
?S |
rdfs:domain |
?O |
_PropertyDomain(?S,?O) |
RDFS range (not part of OL) |
Some examples are given below. The first example is a simple query with two triples in the WHERE part of the SPARQL query.
SELECT *
WHERE {
?CAR a <http://example.com/#car> ;
<http://example.com/#price> ?PRICE
}
This SPARQL query could also be expressed using the ObjectLogic query
?- ?CAR:<http://example.com/#car> AND ?CAR[<http://example.com/#price>->?PRICE].
This example shows a query for subclass relationships. When we have the ObjectLogic ontology:
Developer::Employee.
ProjectManager::Employee.
Then the following query
SELECT ?X
WHERE {
?X rdfs:subClassOf ?Y
}
will return:
X
--------------
Developer
ProjectManager
This SPARQL query could also be expressed with the ObjectLogic query
@{options[outorder(?X)]} ?- ?X::?Y.