Podcast
Questions and Answers
What is the primary function of SPARQL in the Linked Data Stack?
What is the primary function of SPARQL in the Linked Data Stack?
- Establishing trust and security within the Linked Data environment.
- Querying and retrieving data from RDF datasets. (correct)
- Providing a user interface for Linked Data applications.
- Defining the structure and constraints of RDF data.
In a SPARQL query, what is the purpose of defining prefixes?
In a SPARQL query, what is the purpose of defining prefixes?
- To introduce shorthand CURIEs for clearer query syntax. (correct)
- To define the structure of the result table.
- To declare variables that will be used in the query.
- To specify the dataset from which to retrieve data.
Which SPARQL query form is used to verify if a specific pattern exists in the dataset?
Which SPARQL query form is used to verify if a specific pattern exists in the dataset?
- SELECT
- DESCRIBE
- CONSTRUCT
- ASK (correct)
What is the function of the FROM
keyword in a SPARQL query?
What is the function of the FROM
keyword in a SPARQL query?
In SPARQL, what does a basic graph pattern (BGP) represent?
In SPARQL, what does a basic graph pattern (BGP) represent?
What role do variables play within triple patterns in a SPARQL query?
What role do variables play within triple patterns in a SPARQL query?
How does SPARQL handle matching resources?
How does SPARQL handle matching resources?
In SPARQL, what is the purpose of a solution mapping?
In SPARQL, what is the purpose of a solution mapping?
When querying RDF data with SPARQL, what is the function of a FILTER
?
When querying RDF data with SPARQL, what is the function of a FILTER
?
Which function in SPARQL is used to retrieve the lexical form of a literal?
Which function in SPARQL is used to retrieve the lexical form of a literal?
What is the purpose of aggregate functions in SPARQL 1.1?
What is the purpose of aggregate functions in SPARQL 1.1?
In SPARQL, which query type allows the creation of a new graph by binding variables in a provided template?
In SPARQL, which query type allows the creation of a new graph by binding variables in a provided template?
What is a key feature of federated SPARQL endpoint engines?
What is a key feature of federated SPARQL endpoint engines?
What is the main advantage of using named graphs in SPARQL?
What is the main advantage of using named graphs in SPARQL?
Which triple pattern is valid when using SPARQL?
Which triple pattern is valid when using SPARQL?
What is a Blank Node in SPARQL?
What is a Blank Node in SPARQL?
How are logical OR
operations handled using SPARQL?
How are logical OR
operations handled using SPARQL?
What does SERVICE
command do in SPARQL?
What does SERVICE
command do in SPARQL?
How can a SPARQL query specify that it needs to return results from a particular named graph?
How can a SPARQL query specify that it needs to return results from a particular named graph?
When SPARQL does not find a matching value, how does it fill the results?
When SPARQL does not find a matching value, how does it fill the results?
What actions happen if a SPARQL triple includes URIs, but the cases do not match up?
What actions happen if a SPARQL triple includes URIs, but the cases do not match up?
A SPARQL query has a variable name ?zip, if we want to specify that we can accept multiple ?zip values, what do we use?
A SPARQL query has a variable name ?zip, if we want to specify that we can accept multiple ?zip values, what do we use?
What's a key difference between FROM
and FROM NAMED
in SPARQL?
What's a key difference between FROM
and FROM NAMED
in SPARQL?
Which SPARQL keyword helps to eliminate duplicate results?
Which SPARQL keyword helps to eliminate duplicate results?
What's the purpose of OFFSET
in a SPARQL query?
What's the purpose of OFFSET
in a SPARQL query?
What is the impact of using LIMIT
in a SPARQL query?
What is the impact of using LIMIT
in a SPARQL query?
In SPARQL, how do you retrieve data from multiple different sources?
In SPARQL, how do you retrieve data from multiple different sources?
What operator must be used in SPARQL to check that multiple conditions are true?
What operator must be used in SPARQL to check that multiple conditions are true?
If there is a mismatch in datatypes in SPARQL, what should one consider doing?
If there is a mismatch in datatypes in SPARQL, what should one consider doing?
What happens to undeclared variables within tripleResults?
What happens to undeclared variables within tripleResults?
What operation is similar to left join in SQL?
What operation is similar to left join in SQL?
What is a key objective for SPARQL?
What is a key objective for SPARQL?
Under what conditions are Entailment Regimes useful?
Under what conditions are Entailment Regimes useful?
Why is it important and useful for SPARQL to have syntax and semantics covering queries over RDF?
Why is it important and useful for SPARQL to have syntax and semantics covering queries over RDF?
What do SPARQL triple patterns do?
What do SPARQL triple patterns do?
After performing a SPARQL query, what should be the datatypes assigned to the resulting variables?
After performing a SPARQL query, what should be the datatypes assigned to the resulting variables?
What can modifiers do?
What can modifiers do?
How are graphs added?
How are graphs added?
Regarding the order of RDF terms, what is the relationship?
Regarding the order of RDF terms, what is the relationship?
In SPARQL, what is the significance of the 'DISTINCT' keyword used in a SELECT query?
In SPARQL, what is the significance of the 'DISTINCT' keyword used in a SELECT query?
Which SPARQL query form is designed to return a boolean result indicating whether a specific graph pattern exists within the dataset?
Which SPARQL query form is designed to return a boolean result indicating whether a specific graph pattern exists within the dataset?
When constructing a SPARQL query to retrieve information from a specific RDF document located at a given URI, which keyword is used to specify the data source?
When constructing a SPARQL query to retrieve information from a specific RDF document located at a given URI, which keyword is used to specify the data source?
In SPARQL, what is the role of a variable in a triple pattern?
In SPARQL, what is the role of a variable in a triple pattern?
If a SPARQL query includes multiple triple patterns in the WHERE clause, how are these patterns logically combined by default?
If a SPARQL query includes multiple triple patterns in the WHERE clause, how are these patterns logically combined by default?
What is the primary function of the FILTER
keyword in a SPARQL query?
What is the primary function of the FILTER
keyword in a SPARQL query?
Which SPARQL function is used to retrieve the string representation (lexical form) of an RDF literal or the codepoint representation of a URI?
Which SPARQL function is used to retrieve the string representation (lexical form) of an RDF literal or the codepoint representation of a URI?
In SPARQL 1.1, what is the purpose of aggregate functions like COUNT
, SUM
, AVG
, MIN
, and MAX
?
In SPARQL 1.1, what is the purpose of aggregate functions like COUNT
, SUM
, AVG
, MIN
, and MAX
?
Which SPARQL query type is used to create a new RDF graph based on the results of a query and a provided graph template?
Which SPARQL query type is used to create a new RDF graph based on the results of a query and a provided graph template?
What is a key characteristic of federated SPARQL endpoint engines?
What is a key characteristic of federated SPARQL endpoint engines?
What advantage do named graphs offer in SPARQL?
What advantage do named graphs offer in SPARQL?
Identify the valid triple pattern in SPARQL syntax.
Identify the valid triple pattern in SPARQL syntax.
What is a Blank Node in SPARQL queries?
What is a Blank Node in SPARQL queries?
How can logical OR
conditions be implemented within SPARQL graph patterns?
How can logical OR
conditions be implemented within SPARQL graph patterns?
What is the function of the SERVICE
keyword in a SPARQL query?
What is the function of the SERVICE
keyword in a SPARQL query?
How do you target queries to a specific named graph within a SPARQL dataset?
How do you target queries to a specific named graph within a SPARQL dataset?
If a triple pattern in a SPARQL query does not find a match in the RDF data, how are the corresponding variables in the solution mapping handled by default?
If a triple pattern in a SPARQL query does not find a match in the RDF data, how are the corresponding variables in the solution mapping handled by default?
What happens when a SPARQL query attempts to match a URI in a triple pattern, but the case of the URI in the query does not exactly match the case in the RDF dataset?
What happens when a SPARQL query attempts to match a URI in a triple pattern, but the case of the URI in the query does not exactly match the case in the RDF dataset?
In SPARQL, if you want to specify that a variable can accept multiple possible values, which construct should you use?
In SPARQL, if you want to specify that a variable can accept multiple possible values, which construct should you use?
What is the key difference in how FROM
and FROM NAMED
clauses are used in SPARQL?
What is the key difference in how FROM
and FROM NAMED
clauses are used in SPARQL?
Which SPARQL keyword is instrumental in removing duplicate solution mappings from the query result set?
Which SPARQL keyword is instrumental in removing duplicate solution mappings from the query result set?
What is the purpose of the OFFSET
keyword in a SPARQL query?
What is the purpose of the OFFSET
keyword in a SPARQL query?
How does the LIMIT
keyword affect the results of a SPARQL query?
How does the LIMIT
keyword affect the results of a SPARQL query?
How can SPARQL queries access and retrieve data from multiple, distinct RDF sources?
How can SPARQL queries access and retrieve data from multiple, distinct RDF sources?
Which logical operator is used in SPARQL FILTER
expressions to ensure that all specified conditions must be true for a solution to be included?
Which logical operator is used in SPARQL FILTER
expressions to ensure that all specified conditions must be true for a solution to be included?
When encountering datatype mismatches in SPARQL operations, what is a common consideration?
When encountering datatype mismatches in SPARQL operations, what is a common consideration?
What happens to variables that are declared in the SELECT clause of a SPARQL query but are not bound to any value in the query's graph pattern?
What happens to variables that are declared in the SELECT clause of a SPARQL query but are not bound to any value in the query's graph pattern?
Which SPARQL feature provides functionality similar to a left join in SQL, allowing to retrieve results even when some parts of the pattern are not matched?
Which SPARQL feature provides functionality similar to a left join in SQL, allowing to retrieve results even when some parts of the pattern are not matched?
What is a fundamental objective for SPARQL as a query language?
What is a fundamental objective for SPARQL as a query language?
Under what circumstances are Entailment Regimes in SPARQL particularly useful?
Under what circumstances are Entailment Regimes in SPARQL particularly useful?
Why is it considered important and useful for SPARQL to have defined syntax and semantics for querying over RDF?
Why is it considered important and useful for SPARQL to have defined syntax and semantics for querying over RDF?
What is the role of SPARQL triple patterns in the query process?
What is the role of SPARQL triple patterns in the query process?
After executing a SPARQL query, what determines the datatypes assigned to the variables in the resulting solution mappings?
After executing a SPARQL query, what determines the datatypes assigned to the variables in the resulting solution mappings?
What is the function of query modifiers in SPARQL, such as ORDER BY, LIMIT, and OFFSET?
What is the function of query modifiers in SPARQL, such as ORDER BY, LIMIT, and OFFSET?
In the context of SPARQL and RDF datasets, how are graphs typically added to a dataset?
In the context of SPARQL and RDF datasets, how are graphs typically added to a dataset?
Regarding the order of RDF terms (like IRIs, literals, blank nodes) when sorting results in SPARQL using ORDER BY
, what is the general relationship from lowest to highest in sort order?
Regarding the order of RDF terms (like IRIs, literals, blank nodes) when sorting results in SPARQL using ORDER BY
, what is the general relationship from lowest to highest in sort order?
Consider a scenario in SPARQL where you want to retrieve information about resources, but only if a specific property exists. What Group Graph Pattern would you utilize?
Consider a scenario in SPARQL where you want to retrieve information about resources, but only if a specific property exists. What Group Graph Pattern would you utilize?
You need to query data from two different RDF graphs and combine the results into a single result set, even if the structures of the data in each graph differ slightly. Which SPARQL operator is most suitable for this task?
You need to query data from two different RDF graphs and combine the results into a single result set, even if the structures of the data in each graph differ slightly. Which SPARQL operator is most suitable for this task?
In SPARQL, imagine you want to determine if there is any data about the population of Berlin in a given RDF dataset, without needing to know the population figure itself. Which query form is most efficient for this check?
In SPARQL, imagine you want to determine if there is any data about the population of Berlin in a given RDF dataset, without needing to know the population figure itself. Which query form is most efficient for this check?
Given an RDF dataset with information about cities and their properties, you wish to retrieve the names of all cities, ensuring each name appears only once in the result set. Which SPARQL keyword achieves this?
Given an RDF dataset with information about cities and their properties, you wish to retrieve the names of all cities, ensuring each name appears only once in the result set. Which SPARQL keyword achieves this?
Consider needing to write a query to find cities that do not have a 'state' property associated with them using SPARQL. How can you achieve this?
Consider needing to write a query to find cities that do not have a 'state' property associated with them using SPARQL. How can you achieve this?
Flashcards
What is SPARQL?
What is SPARQL?
A protocol and query language for RDF data.
What can you do with Linked Data?
What can you do with Linked Data?
Read and write Resource Description Framework (RDF) triples and access data published according to the Linked Data Principles.
How to retrieve data from a dataset?
How to retrieve data from a dataset?
Queries are used to retrieve relevant data from a dataset.
What is the current version of SPARQL?
What is the current version of SPARQL?
Signup and view all the flashcards
What is the 'PREFIX' keyword used for?
What is the 'PREFIX' keyword used for?
Signup and view all the flashcards
What are the different SPARQL query forms?
What are the different SPARQL query forms?
Signup and view all the flashcards
What is variable projection in SPARQL?
What is variable projection in SPARQL?
Signup and view all the flashcards
What is dataset selection in SPARQL?
What is dataset selection in SPARQL?
Signup and view all the flashcards
What does the FROM clause do?
What does the FROM clause do?
Signup and view all the flashcards
What is the query pattern in SPARQL?
What is the query pattern in SPARQL?
Signup and view all the flashcards
What are SPARQL triple patterns?
What are SPARQL triple patterns?
Signup and view all the flashcards
What is Basic Graph Pattern (BGP)?
What is Basic Graph Pattern (BGP)?
Signup and view all the flashcards
What are Filters in SPARQL?
What are Filters in SPARQL?
Signup and view all the flashcards
What does STR(L U) function return?
What does STR(L U) function return?
Signup and view all the flashcards
Are many SPARQL endpoints available on the Web?
Are many SPARQL endpoints available on the Web?
Signup and view all the flashcards
Study Notes
- This slide set is associated with a lecture on Semantic Web technologies at RWTH Aachen University.
- The slides are based on work by Andreas Harth and Lars Heling, adapted by Lars Gleim
- The material is licensed under Creative Commons Attribution 4.0 International.
Introduction to Querying RDF with SPARQL
- The lecture explores how to access and query descriptions of things using SPARQL
- RDF triples are how to read/write Resource Description Framework
- Data published according to Linked Data Principles can be accessed
- How to write/evaluate queries on RDF datasets is covered this chapter
SPARQL
- Introduction
- Structure of SPARQL Queries
- Basic Graph Patterns
- Group Graph Patterns
- Filters, Functions and Modifiers
- RDF Datasets and Named Graphs
- Querying RDF Data on the Web
Linked Data Stack
- SPARQL sits at the Query layer, working with OWL ontologies and RIF rules
- It uses RDF-Schema for data structure and RDF for data interchange
- Relies on XML and URI, supported by Unicode
Querying RDF Data
- The central question is how to retrieve data from a dataset
- Queries retrieve relevant data
- In relational databases, tuples are stored in tables (relations)
- SQL(Structured Query Language) is the standard language
SPARQL Details
- SPARQL (SPARQL Protocol And RDF Query Language) is specified by W3C
- The current version is SPARQL 1.1, released in March 2013
- There are eleven SPARQL Recommendations covering:
- Syntax and semantics of queries over RDF
- Protocol to pose queries against a SPARQL endpoint
- How to retrieve results, various serializations of query results, entailment regimes, update language, and federated query
SPARQL Query Structure
- SPARQL query structure includes prefix declarations, query type, graph pattern, and query modifiers.
- Prefixes are declared using the
PREFIX
keyword to make queries more readable by shortening URIs. - Example:
PREFIX ex: <http://example.com/resources/>
- The query type specifies what kind of data to retrieve (
SELECT
?x ?y), and the dataset definition indicates where the data comes from (FROM ...
). - The graph pattern is defined in the
WHERE
clause, where triple patterns are specified to match against the RDF data.?x a ?y
- Query modifiers such as
ORDER BY ?y
can be used to sort the results.
Components of SPARQL Queries
- Queries include prefix definitions, dataset specifications, and the query pattern with triple patterns
- Prefix definitions use the
PREFIX
keyword to introduce CURIEs. - CURIE syntax in SPARQL is slightly different from Turtle syntax: the final period is omitted, and there's no "@" at the beginning.
- The
SELECT
form returns variables,ASK
returns a boolean,DESCRIBE
returns a graph describing a resource, andCONSTRUCT
returns a graph based on a template. - Variables act as placeholders and are prefixed with “?” or “$”. To select all variables, use
SELECT *
. - The FROM or FROM NAMED keywords specify the dataset.
- They indicate where to find the data.
- FROM clause specifies graphs for the endpoint to consider; if omitted, the default graph is used
- The dataset selection, using
FROM
orFROM NAMED
, specifies the dataset and indicates the sources for matching data. - Sequence modifiers such as
ORDER BY
change the result order,LIMIT
andOFFSET
select chunks of results, andDISTINCT
removes duplicates.
Prefixes in SPARQL
- Prefixes are syntactic sugar to improve query readability.
- They allow the replacement of long URIs with shorter, prefixed names within the query.
- For example:
PREFIX dc: <http://example.org/base/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
- This makes it possible to write
:Tim
instead of<http://example.com/base/Tim>
andfoaf:knows
instead of<http://xmlns.com/foaf/0.1/knows>
.
Basic Graph Patterns
- Building block of SPRAQL is triple patterns
- Similar to RDF triples but with variables (specified with ? or $)
- Basic Graph Pattern (BGP) contains several triple patterns.
- BGPs can be specified using Turtle syntax and represent a conjunction of triple patterns.
- Variables can be used in the subject, predicate, or object position
- Evaluation involves pattern matching against the RDF graph, where variables are bound to resources that satisfy the pattern.
- The solution sequence of the WHERE clause contains solution mappings even for variables not specified in the SELECT clause.
- Blank nodes in BGPs are treated similarly to variables, but one may not specify blank nodes in the query form
- When used in a CONSTRUCT statement, for each mapping a new blank node is created
Triple Pattern Examples
- For a given dataset, example queries might be:
SELECT ?x WHERE {:Aachen :name ?x}
which retrieves the name of Aachen. Result: "Aachen".SELECT ?x WHERE {:Aachen :locatedIn ?x}
which retrieves where Aachen is located. Result::Germany
.SELECT ?country ?name WHERE {:Aachen :locatedIn ?country; :name ?name}
gives both the country and its name. Result::Germany "Aachen"
.SELECT ?countryName WHERE {:Aachen :locatedIn ?country. ?country :name ?countryName}
resolves the country name. Result:"Germany"
.
Matching Resources and Literals
- SPARQL matches resources by character, either with a prefix or a full URI.
- Case sensitivity is important
- Percent encoding is critical (e.g.,
myns:John%20Doe != myns:John Doe
). - Literals need to match exactly and can have datatypes (xsd:int, xsd:date) and language tags (
@en
,@de
). - Exact matching is required unless the SPARQL engine knows how to interpret the datatype
Solution Mappings
- During query evaluation, RDF terms bind the variables to RDF terms with constants (URIs, blank nodes, or literals) via substitutions
- Syntax for solution mappings is μ(?var) = value
- Value represents the binding (solution) for the variable
Solution Representation
- Solution mappings are also in table form
- Solution order:
- Ω = {µ₁(?borough) = : Pankow
- µ₁(?berlin) = : Berlin
- µ₂(?borough) = : Neukoelln
- µ₂(?berlin) = : Berlin}
Group Graph Patterns
- Allow more control over the structure and logic of query patterns.
- Queries can specify the source graph for triple patterns and use operators such as
OPTIONAL
andUNION
Named Graphs and Graph Patterns
- Named graphs provide more control over which graphs a triple is sourced from
- A graph graph pattern example:
FROM NAMED <http://example.org/citites.ttl>
WHERE { GRAPH ?g { ?city :name “Berlin”. } }
- would return the graph and city where the city name is Berlin.
Operators for Group Graph Patterns
- Using
OPTIONAL
allows for left-join like queries, useful for incomplete data. - For example, retrieving the capital of Germany and optionally its population
?x :capital :Germany .
OPTIONAL { ?x :population ?y . }
- Using
UNION
specifies disjunctions of triple patterns, which allows querying across differing data structures. - Retrieving population figures for either Neukölln or Pankow.
{ :Neukoelln :population ?y . }
UNION
{ :Pankow :population ?y . }
Optional Examples
- For a sample dataset, one can formulate queries using optional patterns.
- For instance:
SELECT ?name ?zip {?city :name ?name. ?city :zip ?zip}
- Would return only cities for which a zip code is listed
- Conversely:
SELECT ?name ?zip {?city : name ?name. OPTIONAL {?city :zip ?zip}}
- would include all cities, listing zip codes when available.
Union Examples
For a given set of city data, queries with UNION
can combine results from different properties:
SELECT ?name WHERE {?city a :City. ?city :name ?name}
retrieves the names of cities with:name
. Results: "Aachen" and "Berlin".
SELECT ?name WHERE {?city a :City. {?city :name ?name} UNION {?city rdfs:label ?name}}
- This combines city names from
:name
andrdfs:label
, returning "Aachen", "Berlin", and "Köln".
Projection
- Variable inclusion/exclusion is possible
- Example:
SELECT * WHERE {.....}
- Includes all variables mentioned in graph pattern
- Only specific variables can be included
- For example: SELECT ?s ?o WHERE {?s ?p ?o}
- Duplicates can be eliminated with SELECT DISTINCT
Filters, Functions, and Modifiers
- Used in conjunction with the WHERE clause
- They are specified, most prominently, using Literal values and the FILTER keyword
- Filters operate on graph patterns and test values, primarily restricting literal values through string comparison, regular expressions, and numeric comparators
- The evaluate to true, false or type error.
- The result of a filter is True/False or Error
- Type/language checks happen
- Operators for filter expressions include
<, =, >, <=, >=, !=
, usable on numeric types, strings, xsd:dateTime and xsd:boolean and operators+, -, *, /
- AND (
&&
), OR (||
), NOT (!
) are how filter expressions can be combined
Numeric Filtering, Logical Operator and String Filtering Examples
Given some data:
:Aachen : population 250000
: Aachen :name "Aachen"@en
:Berlin :population 3500000.
A SELECT query with a numeric filter:
SELECT ?city WHERE {?city : population ?p FILTER (?p>1000000)}
will return :Berlin
. Applying logical operators to the filter. For example, given:
:Aachen : population 250000
:Aachen :name "Aachen"@en
:Berlin :population 3500000.
A select query with a logical operator
SELECT ?city where {?city :name ?n; : population ?p. FILTER (str(?n)="Aachen" && ?p>500000)}
returns NULL
. But:
SELECT ?city where {?city :name ?n; : population ?p.FILTER (str(?n)="Aachen" || ?p>500000)} A SELECT query with a logical operator: SELECT ?city where {?city :name ?n; : population ?p. FILTER (str(?n)="Aachen" || ?p>500000)}
returns :Aachen
and :Berlin
. For a string match filter is the following example is applicable:
SELECT ?city WHERE {?city :name ?name. FILTER (str(?name) = "Berlin")}
will result in
:Berlin A SELECT query with a string match is: SELECT ?city WHERE {?city :name ?name.
FILTER (contains(?name, "erlin"))}
: Berlin
Functions in SPARQL
- Can be used within the filter expression
- Example functions can use as follows:
STR(L U)
return the simple literal/lexical form of a literal or the codepoint representation of an URILANG(L)
returns simple literal where the language teg of a literal is provided
- How to set
WHERE
language
WHERE {
?borough :borough :Berlin ;
:name ?name .
FILTER(lang(?name) = “en”)
)
}
Aggregate Functions
- Aggregate functions similar to SQL include
min
,max
,avg
,sum
, andcount
, and were introduced with SPARQL 1.1. - It’s necessary to `Group by groups the results accordingly, necessary for projection
Modifying the Result Set
- Sequence modifiers are used to edit the solution mapping; four modifiers:
- Modifiers include
ORDER BY
, which sorts results (ASC or DESC),LIMIT
(specifies a number of results to be returned),OFFSET
(starts after a number), andSELECT DISTINCT
(only returns unique solutions).
- Modifiers include
RDF Datasets
- Information may be spread over documents
- Therefore, several documents should be addressable in a query
Multiple Graphs
- SPARQL handles multiple graphs with different data sources via
FROM
- All graphs specified in
FROM
clause are combined to a default graph - SPARQL handles multiple named graphs via
FROM NAMED
and accesses them viaGRAPH
- To identify the triples belonging to a graph data extents th triple model to quadruples
Querying RDF Data on the Web Overview
- The query methods are:
- Link traversal engines for dereferencing resources,
- SPARQL endpoints that execute SPARQL queries, and
- Federated SPARQL endpoint engines for combining results from multiple endpoints.
Link Traversal Engines
- Dereference information resources with RDF descriptions and parse
PREFIX dbr:<http://dbpedia.org/resource/> PREFIX dbo:<http://dbpedia.org/ontology/> SELECT ?x {dbr:India dbo: capital ?x}
- In this case, you must dereference the informaiton resources for RDF descriptions dbo: percentageOfAreawater
- Followed by evaluation of the triple pattern
SPARQL EndPoints (2)
- Servers that can execute SPARQL queries
- Many SPARQL end points are on the web, including DBpedia
Federated SPARQL EndPoint (3)
- Enables SPARQL queries to executes against a set of end points
- Manual specification of an end point via service clause Example:
PREFIX foaf:<http://xmlns.com/foaf/0.1/> PREFIX geonames:<http://www.geonames.org/ontology#> SELECT ?name ?location WHERE {SERVICE <http://lmdb.org/sparql> {?artist foaf:based_near ?location}
{?location geonames:parentFeature ?germany SERVICE <http://dbpedia.org/sparql> ?germany geonames:name 'Federal Republic of Germany}}
Review: Linked Data and SPARQL
-
triple patterns query RDF graphs,
-
SPARQL queries include prefix declarations, specify ask, select, describe or construct, variable patterns, FROM/FROM Named for data sets, Basic Graph Pattern (UNION, OPTIONAL, FILTER), ORDER BY, LIMIT, DISTINCT.
-
Learning Goals*
-
Understand how to query RDF datasets using SPARQL, including writing basic graph pattern queries, use FROM and GRAPH clauses, and correctly apply UNION. You should also know how to use BIND as well as FILTER, how to handle typed literals, and use LIMIT and OFFSET
-
Be able to find all cities that do NOT have a state associated. Using a combination of not, bound and optional
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.