288
Internet of Things (IoT)
13.5 Simple Protocol and RDF Query Language
SPARQL (Prud’Hommeaux and Seaborne 2008) is a standard query language for RDF.
ASPARQL query consists of a set of triples where the subject, predicate, and object can
consist of variables. The idea is to match the triples in the SPARQL query with the existing
RDF triples and find solutions to the variables.
SPARQL 1.0 only allows limited operations on matching results or solutions such as filter
or duplicate elimination, ordering, projection, and triple construction. We need to provide
more flexible operations such as aggregates, grouping, assignment, and select expressions.
SPARQL 1.1 provides all these features.
Like SQL, SPARQL selects data from the query dataset by using a SELECT statement to
determine which subset of the selected data is returned. Also, SPARQL uses a WHERE
clause to define graph patterns to find a match for in the query data set. A graph pattern
in a SPARQL WHERE clause consists of the subject, predicate, and object triple to find a
match for in the data.
SPARQL General Form
PREFIX (Namespace Prefixes)
e.g., PREFIX iot: < http://purl.org/IoT/iot#>
SELECT (Result Set)
e.g., SELECT ?sensorname
WHERE (Query Triple Pattern)
e.g., WHERE iot:?sensorname iot:location iot:?room1
ORDER BY(modifier)
e.g., ORDER BY ?sensorname
13.6 Case Study
A number of use cases have been recognized such as web portals, corporate web site
management, agents and services, web services, and ubiquitous computing where web
TABLE 13.10 (Continued)
Built-Ins for Lists
Built-Ins
Syntax and Comment
swrlb:member
swrlb:member(?x,?y)
- argument1 is a member of argument2
swrlb:length
swrlb:length (?x,?y)
- argument1 is the length of argument2
swrlb:rest
swrlb:rest(?x,?y)
- argument1 is a list that consists of all members of argument2 except the first member
swrlb:first
swrlb:first(?x,?y)
- argument1 is the first member of argument2(list type)
swrlb:empty
swrlb:empty(?x)
- return if argument1 is an empty list
swrlb:sublist
swrlb:sublist(?x,?y)
- argument1 contains sublist of argument2
Internet of Things (IoT)
13.5 Simple Protocol and RDF Query Language
SPARQL (Prud’Hommeaux and Seaborne 2008) is a standard query language for RDF.
ASPARQL query consists of a set of triples where the subject, predicate, and object can
consist of variables. The idea is to match the triples in the SPARQL query with the existing
RDF triples and find solutions to the variables.
SPARQL 1.0 only allows limited operations on matching results or solutions such as filter
or duplicate elimination, ordering, projection, and triple construction. We need to provide
more flexible operations such as aggregates, grouping, assignment, and select expressions.
SPARQL 1.1 provides all these features.
Like SQL, SPARQL selects data from the query dataset by using a SELECT statement to
determine which subset of the selected data is returned. Also, SPARQL uses a WHERE
clause to define graph patterns to find a match for in the query data set. A graph pattern
in a SPARQL WHERE clause consists of the subject, predicate, and object triple to find a
match for in the data.
SPARQL General Form
PREFIX (Namespace Prefixes)
e.g., PREFIX iot: < http://purl.org/IoT/iot#>
SELECT (Result Set)
e.g., SELECT ?sensorname
WHERE (Query Triple Pattern)
e.g., WHERE iot:?sensorname iot:location iot:?room1
ORDER BY(modifier)
e.g., ORDER BY ?sensorname
13.6 Case Study
A number of use cases have been recognized such as web portals, corporate web site
management, agents and services, web services, and ubiquitous computing where web
TABLE 13.10 (Continued)
Built-Ins for Lists
Built-Ins
Syntax and Comment
swrlb:member
swrlb:member(?x,?y)
- argument1 is a member of argument2
swrlb:length
swrlb:length (?x,?y)
- argument1 is the length of argument2
swrlb:rest
swrlb:rest(?x,?y)
- argument1 is a list that consists of all members of argument2 except the first member
swrlb:first
swrlb:first(?x,?y)
- argument1 is the first member of argument2(list type)
swrlb:empty
swrlb:empty(?x)
- return if argument1 is an empty list
swrlb:sublist
swrlb:sublist(?x,?y)
- argument1 contains sublist of argument2
