I used these slides for an introductory lecture (90min) to a seminar on SPARQL. This slideset introduces the RDF query language SPARQL from a user's perspective.
"SPARQL Cheat Sheet" is a short collection of slides intended to act as a guide to SPARQL developers. It includes the syntax and structure of SPARQL queries, common SPARQL prefixes and functions, and help with RDF datasets.
The "SPARQL Cheat Sheet" is intended to accompany the SPARQL By Example slides available at http://www.cambridgesemantics.com/2008/09/sparql-by-example/ .
"SPARQL Cheat Sheet" is a short collection of slides intended to act as a guide to SPARQL developers. It includes the syntax and structure of SPARQL queries, common SPARQL prefixes and functions, and help with RDF datasets.
The "SPARQL Cheat Sheet" is intended to accompany the SPARQL By Example slides available at http://www.cambridgesemantics.com/2008/09/sparql-by-example/ .
RDF is a general method to decompose knowledge into small pieces, with some rules about the semantics or meaning of those pieces. The point is to have a method so simple that it can express any fact, and yet so structured that computer applications can do useful things with knowledge expressed in RDF.
SPARQL introduction and training (130+ slides with exercices)Thomas Francart
Full SPARQL training
Covers all SPARQL : basic graph patterns, FILTERs, functions, property paths, optional, negation, assignation, aggregation, subqueries, federated queries.
Does not cover except SPARQL updates.
Includes exercices on DBPedia.
CC BY license
Understanding RDF: the Resource Description Framework in Context (1999)Dan Brickley
Dan Brickley, 3rd European Commission Metadata Workshop, Luxemburg, April 12th 1999
Understanding RDF: the Resource Description Framework in Context
http://ilrt.org/discovery/2001/01/understanding-rdf/
OWL stands for Web Ontology Language
OWL is built on top of RDF
OWL is for processing information on the web
OWL was designed to be interpreted by computers
OWL was not designed for being read by people
OWL is written in XML
OWL has three sublanguages
- OWL Lite , OWL DL , OWL Full
OWL is a W3C standard
Wikidata tutorial presented at the U.S. National Archives on October 10, 2015 as part of WikiConference USA.
Contains edits and corrections from version presented.
Released under CC0.
Semantic Web technologies (such as RDF and SPARQL) excel at bringing together diverse data in a world of independent data publishers and consumers. Common ontologies help to arrive at a shared understanding of the intended meaning of data.
However, they don’t address one critically important issue: What does it mean for data to be complete and/or valid? Semantic knowledge graphs without a shared notion of completeness and validity quickly turn into a Big Ball of Data Mud.
The Shapes Constraint Language (SHACL), an upcoming W3C standard, promises to help solve this problem. By keeping semantics separate from validity, SHACL makes it possible to resolve a slew of data quality and data exchange issues.
Presented at the Lotico Berlin Semantic Web Meetup.
RDF is a general method to decompose knowledge into small pieces, with some rules about the semantics or meaning of those pieces. The point is to have a method so simple that it can express any fact, and yet so structured that computer applications can do useful things with knowledge expressed in RDF.
SPARQL introduction and training (130+ slides with exercices)Thomas Francart
Full SPARQL training
Covers all SPARQL : basic graph patterns, FILTERs, functions, property paths, optional, negation, assignation, aggregation, subqueries, federated queries.
Does not cover except SPARQL updates.
Includes exercices on DBPedia.
CC BY license
Understanding RDF: the Resource Description Framework in Context (1999)Dan Brickley
Dan Brickley, 3rd European Commission Metadata Workshop, Luxemburg, April 12th 1999
Understanding RDF: the Resource Description Framework in Context
http://ilrt.org/discovery/2001/01/understanding-rdf/
OWL stands for Web Ontology Language
OWL is built on top of RDF
OWL is for processing information on the web
OWL was designed to be interpreted by computers
OWL was not designed for being read by people
OWL is written in XML
OWL has three sublanguages
- OWL Lite , OWL DL , OWL Full
OWL is a W3C standard
Wikidata tutorial presented at the U.S. National Archives on October 10, 2015 as part of WikiConference USA.
Contains edits and corrections from version presented.
Released under CC0.
Semantic Web technologies (such as RDF and SPARQL) excel at bringing together diverse data in a world of independent data publishers and consumers. Common ontologies help to arrive at a shared understanding of the intended meaning of data.
However, they don’t address one critically important issue: What does it mean for data to be complete and/or valid? Semantic knowledge graphs without a shared notion of completeness and validity quickly turn into a Big Ball of Data Mud.
The Shapes Constraint Language (SHACL), an upcoming W3C standard, promises to help solve this problem. By keeping semantics separate from validity, SHACL makes it possible to resolve a slew of data quality and data exchange issues.
Presented at the Lotico Berlin Semantic Web Meetup.
I used these slides for an introductory lecture (90min) to a seminar on SPARQL. This slideset introduces the semantics of the RDF query language SPARQL.
Sesam4 project presentation sparql - april 2011Robert Engels
This slide set is a provided by the SESAM4 consortium as one out of three Technology Primers on Semantic Web technology. This Primer is on SPARQL and gives you a short introduction to its constructs followed by some examples. You can find the belonging slideset at youtube,
Sesam4 project presentation sparql - april 2011sesam4able
This slide set is a provided by the SESAM4 consortium as one out of three Technology Primers on Semantic Web technology. This Primer is on SPARQL and gives you a short introduction to its constructs followed by some examples. You can find the belonging slideset at youtube under SESAM4.
We present a new version of the data model stRDF and the query language stSPARQL for the representation and querying of geospatial data. The new versions of stRDF and stSPARQL use OGC standards to represent geometries where the original version of stSPARQL used linear constraints. In this sense stSPARQL is a subset of the recent standard GeoSPARQL proposed by OGC. We discuss the implementation of the system Strabon which is a storage and query evaluation module for stRDF/stSPARQL and the corresponding subset of GeoSPARQL. We study the performance of Strabon experimentally and show that it scales to very large data volumes.
Open Standards for the Semantic Web: XML / RDF(S) / OWL / SOAPPieter De Leenheer
This lecture elaborates on RDF, RDFS, and SOAP starting from a short recap of XML, and the history of the W3C and the development of "open standard recommendations". We also compare RDF triples with DOGMA lexons. We finalise by listing shortcomings of RDFS regarding semantics, and give short overview of the history of OWL as one answer to this. A full elaboration on OWL and description logic is for another lecture.
Compare and contrast RDF triple stores and NoSQL: are triples stores NoSQL or not?
Talk given 2011-09-08 tot he BigData/NoSQL meetup at Bristol University.
SWRL is a semantic web rule language that combines OWL ontologies with Horn Logic rules of the RuleML family of rule languages. Being supported by Protégé as well as by popular rule engines and ontology reasoners, such as Jess, Drools and Pellet, SWRL has become a very popular choice for developing rule-based applications on top of ontologies. However, being doubtful whether SWRL will become a W3C standard, it is difficult to reach out to the industrial world. On the other hand, SPIN has become a de-facto industry standard to rep-resent SPARQL rules and constraints on Semantic Web models, building on the widespread acceptance of the SPARQL query language. In this paper, we argue that the life of existing SWRL rule-based ontology applications can be prolonged by being transformed into SPIN. To this end, we have developed a prototype tool using SWI-Prolog that takes as input an OWL ontology with a SWRL rule base and transforms SWRL rules into SPIN rules in the same ontology, taking into consideration the object-oriented scent of SPIN, i.e. linking rules to the appropriate ontology classes as derived by analyzing the rule conditions.
LDQL: A Query Language for the Web of Linked DataOlaf Hartig
I used this slideset to present our research paper at the 14th Int. Semantic Web Conference (ISWC 2015). Find a preprint of the paper here:
http://olafhartig.de/files/HartigPerez_ISWC2015_Preprint.pdf
Rethinking Online SPARQL Querying to Support Incremental Result VisualizationOlaf Hartig
These are the slides of my invited talk at the 5th Int. Workshop on Usage Analysis and the Web of Data (USEWOD 2015): http://usewod.org/usewod2015.html
The abstract of this talks is given as follows:
To reduce user-perceived response time many interactive Web applications visualize information in a dynamic, incremental manner. Such an incremental presentation can be particularly effective for cases in which the underlying data processing systems are not capable of completely answering the users' information needs instantaneously. An example of such systems are systems that support live querying of the Web of Data, in which case query execution times of several seconds, or even minutes, are an inherent consequence of these systems' ability to guarantee up-to-date results. However, support for an incremental result visualization has not received much attention in existing work on such systems. Therefore, the goal of this talk is to discuss approaches that enable query systems for the Web of Data to return query results incrementally.
An Overview on PROV-AQ: Provenance Access and QueryOlaf Hartig
The slides which I used at the Dagstuhl seminar on Principles of Provenance (Feb.2012) for presenting the main contributions and open issues of the PROV-AQ document created by the W3C provenance working group.
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...James Anderson
Effective Application Security in Software Delivery lifecycle using Deployment Firewall and DBOM
The modern software delivery process (or the CI/CD process) includes many tools, distributed teams, open-source code, and cloud platforms. Constant focus on speed to release software to market, along with the traditional slow and manual security checks has caused gaps in continuous security as an important piece in the software supply chain. Today organizations feel more susceptible to external and internal cyber threats due to the vast attack surface in their applications supply chain and the lack of end-to-end governance and risk management.
The software team must secure its software delivery process to avoid vulnerability and security breaches. This needs to be achieved with existing tool chains and without extensive rework of the delivery processes. This talk will present strategies and techniques for providing visibility into the true risk of the existing vulnerabilities, preventing the introduction of security issues in the software, resolving vulnerabilities in production environments quickly, and capturing the deployment bill of materials (DBOM).
Speakers:
Bob Boule
Robert Boule is a technology enthusiast with PASSION for technology and making things work along with a knack for helping others understand how things work. He comes with around 20 years of solution engineering experience in application security, software continuous delivery, and SaaS platforms. He is known for his dynamic presentations in CI/CD and application security integrated in software delivery lifecycle.
Gopinath Rebala
Gopinath Rebala is the CTO of OpsMx, where he has overall responsibility for the machine learning and data processing architectures for Secure Software Delivery. Gopi also has a strong connection with our customers, leading design and architecture for strategic implementations. Gopi is a frequent speaker and well-known leader in continuous delivery and integrating security into software delivery.
Generating a custom Ruby SDK for your web service or Rails API using Smithyg2nightmarescribd
Have you ever wanted a Ruby client API to communicate with your web service? Smithy is a protocol-agnostic language for defining services and SDKs. Smithy Ruby is an implementation of Smithy that generates a Ruby SDK using a Smithy model. In this talk, we will explore Smithy and Smithy Ruby to learn how to generate custom feature-rich SDKs that can communicate with any web service, such as a Rails JSON API.
Securing your Kubernetes cluster_ a step-by-step guide to success !KatiaHIMEUR1
Today, after several years of existence, an extremely active community and an ultra-dynamic ecosystem, Kubernetes has established itself as the de facto standard in container orchestration. Thanks to a wide range of managed services, it has never been so easy to set up a ready-to-use Kubernetes cluster.
However, this ease of use means that the subject of security in Kubernetes is often left for later, or even neglected. This exposes companies to significant risks.
In this talk, I'll show you step-by-step how to secure your Kubernetes cluster for greater peace of mind and reliability.
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualityInflectra
In this insightful webinar, Inflectra explores how artificial intelligence (AI) is transforming software development and testing. Discover how AI-powered tools are revolutionizing every stage of the software development lifecycle (SDLC), from design and prototyping to testing, deployment, and monitoring.
Learn about:
• The Future of Testing: How AI is shifting testing towards verification, analysis, and higher-level skills, while reducing repetitive tasks.
• Test Automation: How AI-powered test case generation, optimization, and self-healing tests are making testing more efficient and effective.
• Visual Testing: Explore the emerging capabilities of AI in visual testing and how it's set to revolutionize UI verification.
• Inflectra's AI Solutions: See demonstrations of Inflectra's cutting-edge AI tools like the ChatGPT plugin and Azure Open AI platform, designed to streamline your testing process.
Whether you're a developer, tester, or QA professional, this webinar will give you valuable insights into how AI is shaping the future of software delivery.
JMeter webinar - integration with InfluxDB and GrafanaRTTS
Watch this recorded webinar about real-time monitoring of application performance. See how to integrate Apache JMeter, the open-source leader in performance testing, with InfluxDB, the open-source time-series database, and Grafana, the open-source analytics and visualization application.
In this webinar, we will review the benefits of leveraging InfluxDB and Grafana when executing load tests and demonstrate how these tools are used to visualize performance metrics.
Length: 30 minutes
Session Overview
-------------------------------------------
During this webinar, we will cover the following topics while demonstrating the integrations of JMeter, InfluxDB and Grafana:
- What out-of-the-box solutions are available for real-time monitoring JMeter tests?
- What are the benefits of integrating InfluxDB and Grafana into the load testing stack?
- Which features are provided by Grafana?
- Demonstration of InfluxDB and Grafana using a practice web application
To view the webinar recording, go to:
https://www.rttsweb.com/jmeter-integration-webinar
UiPath Test Automation using UiPath Test Suite series, part 3DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 3. In this session, we will cover desktop automation along with UI automation.
Topics covered:
UI automation Introduction,
UI automation Sample
Desktop automation flow
Pradeep Chinnala, Senior Consultant Automation Developer @WonderBotz and UiPath MVP
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Albert Hoitingh
In this session I delve into the encryption technology used in Microsoft 365 and Microsoft Purview. Including the concepts of Customer Key and Double Key Encryption.
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Jeffrey Haguewood
Sidekick Solutions uses Bonterra Impact Management (fka Social Solutions Apricot) and automation solutions to integrate data for business workflows.
We believe integration and automation are essential to user experience and the promise of efficient work through technology. Automation is the critical ingredient to realizing that full vision. We develop integration products and services for Bonterra Case Management software to support the deployment of automations for a variety of use cases.
This video focuses on the notifications, alerts, and approval requests using Slack for Bonterra Impact Management. The solutions covered in this webinar can also be deployed for Microsoft Teams.
Interested in deploying notification automations for Bonterra Impact Management? Contact us at sales@sidekicksolutionsllc.com to discuss next steps.
Assuring Contact Center Experiences for Your Customers With ThousandEyes
An Introduction to SPARQL
1. SPARQL - Querying the Web of Data
Seminar WS 2008/2009
An Introduction to SPARQL
Olaf Hartig
hartig@informatik.hu-berlin.de
2. SPARQL in General
SPARQL Protocol and RDF Query Language
●
SPARQL Query Language for RDF
●
Declarative
●
Based on the RDF data model (triples/graph)
●
Our focus
●
SPARQL Query Results XML Format
●
Representation of the results of SPARQL queries
●
SPARQL Protocol for RDF
●
Transmission of SPARQL queries and the results
●
SPARQL endpoint: Web service that implements the
●
protocol
An Introduction to SPARQL 2
3. Main Idea of SPARQL Queries
Main idea: pattern matching
●
Describe subgraphs of the queried RDF graph
●
Subgraphs that match your description yield a result
●
Mean: graph patterns (i.e. RDF graphs with variables)
●
rdf:type
?v
umbel-sc:Volcano
An Introduction to SPARQL 3
4. Main Idea of SPARQL Queries
Queried
graph:
rdf:type
dbpedia:Mount_Baker umbel-sc:Volcano
p:lastEruption rdf:type
quot;1880quot; dbpedia:Mount_Etna
rdf:type
?v
umbel-sc:Volcano
Results:
?v
dbpedia:Mount_Baker
dbpedia:Mount_Etna
An Introduction to SPARQL 4
5. Components of SPARQL Queries
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX umbel-sc: <http://umbel.org/umbel/sc/>
SELECT ?v
FROM <http://example.org/myGeoData>
WHERE {
?v rdf:type umbel-sc:Volcano .
}
ORDER BY ?name
An Introduction to SPARQL 5
6. Components of SPARQL Queries
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX umbel-sc: <http://umbel.org/umbel/sc/>
SELECT ?v
FROM <http://example.org/myGeoData>
WHERE {
?v rdf:type umbel-sc:Volcano .
}
ORDER BY ?name
Prologue:
●
Prefix definitions enable CURIEs in the query
●
Attention: No period (“.”) character to separate (as in N3)
●
An Introduction to SPARQL 6
7. Components of SPARQL Queries
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX umbel-sc: <http://umbel.org/umbel/sc/>
SELECT ?v
FROM <http://example.org/myGeoData>
WHERE {
?v rdf:type umbel-sc:Volcano .
}
ORDER BY ?name
Result form specification:
●
SELECT, DESCRIBE, CONSTRUCT, or ASK
●
SELECT: - Variable list or asterisk (“*”) character for all
●
- DISTINCT for disjoint results
An Introduction to SPARQL 7
8. Components of SPARQL Queries
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX umbel-sc: <http://umbel.org/umbel/sc/>
SELECT ?v
FROM <http://example.org/myGeoData>
WHERE {
?v rdf:type umbel-sc:Volcano .
}
ORDER BY ?name
Dataset specification:
●
Specify the dataset to be queried
●
Use FROM and FROM NAMED clauses (each with a URI)
●
An Introduction to SPARQL 8
9. Components of SPARQL Queries
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX umbel-sc: <http://umbel.org/umbel/sc/>
SELECT ?v
FROM <http://example.org/myGeoData>
WHERE {
?v rdf:type umbel-sc:Volcano .
}
ORDER BY ?name
Query Pattern:
●
WHERE clause specifies the graph pattern to be matched
●
An Introduction to SPARQL 9
10. Components of SPARQL Queries
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX umbel-sc: <http://umbel.org/umbel/sc/>
SELECT ?v
FROM <http://example.org/myGeoData>
WHERE {
?v rdf:type umbel-sc:Volcano .
}
ORDER BY ?name
Solution modifiers:
●
Modify the result set, but not the single results
●
ORDER BY, LIMIT, or OFFSET
●
An Introduction to SPARQL 10
11. Graph Patterns
Different types of graph patterns for the query pattern
●
(WHERE clause):
Basic graph pattern (BGP)
●
Group graph pattern
●
Optional graph pattern
●
Union graph pattern
●
Graph graph pattern
●
(Constraints)
●
An Introduction to SPARQL 11
12. Basic Graph Patterns
Set of triple patterns (i.e. RDF triples with variables)
●
Variable names prefixed with “?” or “$” (e.g. ?v, $v)
●
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX umbel-sc: <http://umbel.org/umbel/sc/>
SELECT ?name
WHERE {
?v rdf:type umbel-sc:Volcano .
?v rdfs:label ?name .
}
An Introduction to SPARQL 12
13. Basic Graph Patterns
Set of triple patterns (i.e. RDF triples with variables)
●
Variable names prefixed with “?” or “$” (e.g. ?v, $v)
●
Turtle syntax (similar to N3)
●
Syntactical sugar as in N3 (e.g. property and object lists)
●
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX umbel-sc: <http://umbel.org/umbel/sc/>
SELECT ?name
WHERE {
?v rdf:type umbel-sc:Volcano ;
rdfs:label ?name .
}
An Introduction to SPARQL 13
14. Basic Graph Patterns
Data*
dbpedia:Mount_Etna rdf:type umbel-sc:Volcano ;
rdfs:label quot;Etnaquot; .
dbpedia:Mount_Baker rdf:type umbel-sc:Volcano.
dbpedia:Beerenberg rdf:type umbel-sc:Volcano,
umbel-sc:NaturalElevation ;
rdfs:label quot;Beerenbergquot;@en ;
rdfs:label quot;Бееренбергquot;@ru .
Question: What are the names of all (known) volcanos?
●
Result:
Query*
SELECT ?name WHERE {
?name
?v rdf:type umbel-sc:Volcano ;
quot;Etnaquot;
rdfs:label ?name . }
quot;Бееренбергquot;@ru
quot;Beerenbergquot;@en
*Prefix definitions omitted
An Introduction to SPARQL 14
15. Basic Graph Patterns
Data
dbpedia:Mount_Etna rdf:type umbel-sc:Volcano ;
rdfs:label quot;Etnaquot; .
dbpedia:Mount_Baker rdf:type umbel-sc:Volcano.
dbpedia:Beerenberg rdf:type umbel-sc:Volcano,
umbel-sc:NaturalElevation ;
rdfs:label quot;Beerenbergquot;@en ;
rdfs:label quot;Бееренбергquot;@ru .
Question: List all types of the volcano called “Beerenberg”
●
Query
SELECT ?type WHERE {
?type
?v rdf:type ?type ;
rdfs:label quot;Beerenbergquot; .
}
An Introduction to SPARQL 15
16. Basic Graph Patterns
Data
dbpedia:Mount_Etna rdf:type umbel-sc:Volcano ;
rdfs:label quot;Etnaquot; .
dbpedia:Mount_Baker rdf:type umbel-sc:Volcano.
dbpedia:Beerenberg rdf:type umbel-sc:Volcano,
umbel-sc:NaturalElevation ;
rdfs:label quot;Beerenbergquot;@en ;
rdfs:label quot;Бееренбергquot;@ru .
Question: List all types of the volcano called “Beerenberg”
●
Query
SELECT ?type WHERE {
?v rdf:type ?type ; ?type
rdfs:label quot;Beerenbergquot;@en .
umbel-sc:Volcano
} umbel-sc:NaturalElevation
An Introduction to SPARQL 16
17. Basic Graph Patterns
Data
dbpedia:Mount_Baker rdf:type umbel-sc:Volcano ;
p:location dbpedia:United_States .
dbpedia:United_States rdfs:label quot;United Statesquot; .
Question: Where are all (known) volcanos located? List
●
the names.
Blank nodes in SPARQL queries
●
Permitted as subject and object of a triple pattern
●
Like non-selectable variables
●
Query
SELECT ?name WHERE {
?name
_:x rdf:type umbel-sc:Volcano ;
quot;United Statesquot;
p:location [ rdfs:label ?name ] . }
An Introduction to SPARQL 17
18. Basic Graph Patterns
Data
dbpedia:Mount_Baker rdf:type umbel-sc:Volcano ;
p:location [ rdfs:label quot;United Statesquot;@en ,
quot;États-Unisquot;@fr ] .
dbpedia:Mount_Etna rdf:type umbel-sc:Volcano ;
p:location [ rdfs:label quot;Italyquot; ] .
Blank nodes in the queried graph
●
Blank node identifiers may occur in the results
●
Query
SELECT ?l ?name WHERE {
?l ?name
?v rdf:type umbel-sc:Volcano ;
_:x quot;United Statesquot;@en
p:location ?l .
_:x quot;États-Unisquot;@fr
?l rdfs:label ?name .
_:y quot;Italyquot;
}
An Introduction to SPARQL 18
19. Optional Graph Patterns
Data
dbpedia:Mount_Etna rdf:type umbel-sc:Volcano ;
rdfs:label quot;Etnaquot; .
dbpedia:Mount_Baker rdf:type umbel-sc:Volcano .
dbpedia:Beerenberg rdf:type umbel-sc:Volcano ;
rdfs:label quot;Beerenbergquot;@en .
Question: What are all (known) volcanos and their names?
●
Query
SELECT ?v ?name WHERE {
?v rdf:type umbel-sc:Volcano ;
rdfs:label ?name . }
?v ?name
Problem: Mount
●
dbpedia:Mount_Etna quot;Etnaquot;
Baker missing
dbpedia:Beerenberg quot;Beerenbergquot;@en
(it has no name)
An Introduction to SPARQL 19
20. Optional Graph Patterns
Keyword OPTIONAL allows for optional patterns
●
Query
SELECT ?v ?name WHERE {
?v rdf:type umbel-sc:Volcano .
OPTIONAL { ?v rdfs:label ?name }
}
?v ?name
dbpedia:Mount_Etna quot;Etnaquot;
dbpedia:Mount_Baker
dbpedia:Beerenberg quot;Beerenbergquot;@en
Optional patterns may yield unbound variables
●
An Introduction to SPARQL 20
21. Union Graph Patterns
Data
dbpedia:Mount_Etna rdf:type umbel-sc:Volcano ;
rdfs:label quot;Etnaquot; ;
p:location dbpedia:Italy .
dbpedia:Mount_Baker rdf:type umbel-sc:Volcano ;
p:location dbpedia:United_States .
dbpedia:Beerenberg rdf:type umbel-sc:Volcano ;
rdfs:label quot;Beerenbergquot;@en ;
p:location dbpedia:Norway .
Question: What volcanos are located in the Italy or in
●
Norway?
Query
SELECT ?v WHERE {
?v rdf:type umbel-sc:Volcano ;
?
p:location .}
An Introduction to SPARQL 21
22. Union Graph Patterns
Union graph patterns allow for alternatives
●
Query
SELECT ?v WHERE {
{ ?v rdf:type umbel-sc:Volcano ;
Semantically p:location dbpedia:Italy }
equivalent
UNION
{ ?v rdf:type umbel-sc:Volcano ;
p:location dbpedia:Norway }
}
SELECT ?v WHERE { ?v rdf:type umbel-sc:Volcano .
{ ?v p:location dbpedia:Italy }
UNION
{ ?v p:location dbpedia:Norway }
Query
}
An Introduction to SPARQL 22
23. Group Graph Patterns
SELECT ?v WHERE { ?v rdf:type umbel-sc:Volcano .
{ ?v p:location dbpedia:Italy }
UNION
{ ?v p:location dbpedia:Norway }
Query
}
Semantically equivalent
SELECT ?v WHERE { { ?v rdf:type umbel-sc:Volcano }
{ { ?v p:location dbpedia:Italy }
UNION
{ ?v p:location dbpedia:Norway } }
Query
}
An Introduction to SPARQL 23
24. Constraints
Constraints filter solutions
●
Keyword FILTER followed by expression
●
Filter expressions contain operators and functions
●
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX umbel-sc: <http://umbel.org/umbel/sc/>
PREFIX p: <http://dbpedia.org/property/>
SELECT ?v
WHERE {
?v rdf:type umbel-sc:Volcano ;
p:lastEruption ?le .
FILTER ( ?le > 1900 )
}
An Introduction to SPARQL 24
25. Constraints
Operators and functions operate on RDF terms
●
Filter expressions evaluate to true, false, or error
●
Truth table:
●
A B A || B A && B
T T T T
T F T F
F T T F
F F F F
T E T E
E T T E
F E E F
E F E F
E E E E
An Introduction to SPARQL 25
26. Constraints
Unary operators:
●
Operator Type(A) Result type
!A xsd:boolean xsd:boolean
+A numeric numeric
-A numeric numeric
BOUND(A) variable xsd:boolean
isURI(A) RDF term xsd:boolean
isBLANK(A) RDF term xsd:boolean
isLITERAL(A) RDF term xsd:boolean
STR(A) literal / URI simple literal
LANG(A) literal simple literal
DATATYPE(A) literal simple literal
An Introduction to SPARQL 26
27. Constraints
Data
dbpedia:Mount_Etna rdf:type umbel-sc:Volcano ;
rdfs:label quot;Etnaquot; .
dbpedia:Beerenberg rdf:type umbel-sc:Volcano,
umbel-sc:NaturalElevation ;
rdfs:label quot;Beerenbergquot;@en ;
rdfs:label quot;Бееренбергquot;@ru .
Question: List all types of the volcano called “Beerenberg”
●
?type
Query
SELECT ?type WHERE {
umbel-sc:Volcano
?v rdf:type ?type ;
umbel-sc:NaturalElevation
rdfs:label ?name .
FILTER ( STR(?name) = quot;Beerenbergquot; )
}
An Introduction to SPARQL 27
28. Constraints
Binary operators:
●
Logical connectives && and || for xsd:boolean
●
Comparison operators =, !=, <, >, <=, and >= for numeric
●
datatypes, xsd:dateTime, xsd:string, and xsd:boolean
Comparison operators = and != for other datatypes
●
Arithmetic operators +, -, *, and / for numeric datatypes
●
Furthermore:
●
REGEX(String,Pattern) or REGEX(String,Pattern,Flags)
●
sameTERM(A,B)
●
langMATCHES(A,B)
●
An Introduction to SPARQL 28
29. Constraints
Data
dbpedia:Mount_Etna rdf:type umbel-sc:Volcano ;
rdfs:label quot;Etnaquot; .
dbpedia:Beerenberg rdf:type umbel-sc:Volcano,
umbel-sc:NaturalElevation ;
rdfs:label quot;Beerenbergquot;@en ;
rdfs:label quot;Бееренбергquot;@ru .
Question: What volcanos have an “e” in their name?
●
Query
SELECT ?v WHERE {
?v
?v rdf:type umbel-sc:Volcano ;
dbpedia:Beerenberg
rdfs:label ?name .
dbpedia:Beerenberg
FILTER( REGEX(STR(?name),quot;equot;) )
}
An Introduction to SPARQL 29
30. Constraints
Data
dbpedia:Mount_Etna rdf:type umbel-sc:Volcano ;
rdfs:label quot;Etnaquot; .
dbpedia:Beerenberg rdf:type umbel-sc:Volcano,
umbel-sc:NaturalElevation ;
rdfs:label quot;Beerenbergquot;@en ;
rdfs:label quot;Бееренбергquot;@ru .
Question: What volcanos have an “e” in their name?
●
Query
SELECT ?v WHERE {
?v
?v rdf:type umbel-sc:Volcano ;
dbpedia:Mount_Etna
rdfs:label ?name .
dbpedia:Beerenberg
FILTER( REGEX(STR(?name),quot;equot;,quot;iquot;) )
dbpedia:Beerenberg
}
An Introduction to SPARQL 30
31. Negation
Data
dbpedia:Mount_Etna rdf:type umbel-sc:Volcano ;
rdfs:label quot;Etnaquot; .
dbpedia:Mount_Baker rdf:type umbel-sc:Volcano .
dbpedia:Beerenberg rdf:type umbel-sc:Volcano ;
rdfs:label quot;Beerenbergquot;@en ;
rdfs:label quot;Бееренбергquot;@ru .
Question: What volcanos do not have a name in our data?
●
Query
SELECT ?v WHERE {
?v rdf:type umbel-sc:Volcano .
?v
OPTIONAL { ?v rdfs:label ?name }
dbpedia:Mount_Baker
FILTER( ! BOUND(?name) )
}
An Introduction to SPARQL 31
32. Negation
Data
dbpedia:Mount_Etna rdf:type umbel-sc:Volcano ;
rdfs:label quot;Etnaquot; .
dbpedia:Mount_Baker rdf:type umbel-sc:Volcano .
dbpedia:Beerenberg rdf:type umbel-sc:Volcano ;
rdfs:label quot;Beerenbergquot;@en ;
rdfs:label quot;Бееренбергquot;@ru .
Question: What volcanos are not called “Beerenberg”?
●
Query
SELECT ?v WHERE {
!=
?v rdf:type umbel-sc:Volcano .
rdfs:label ?name .
?v
FILTER (STR(?name) != quot;Beerenbergquot;)
dbpedia:Mount_Etna
}
dbpedia:Mount_Baker
dbpedia:Beerenberg 32
An Introduction to SPARQL
33. Negation
Data
dbpedia:Mount_Etna rdf:type umbel-sc:Volcano ;
rdfs:label quot;Etnaquot; .
dbpedia:Mount_Baker rdf:type umbel-sc:Volcano .
dbpedia:Beerenberg rdf:type umbel-sc:Volcano ;
rdfs:label quot;Beerenbergquot;@en ;
rdfs:label quot;Бееренбергquot;@ru .
Question: What volcanos are not called “Beerenberg”?
●
?v
Query
SELECT ?v WHERE {
dbpedia:Mount_Etna
?v rdf:type umbel-sc:Volcano .
dbpedia:Mount_Baker
OPTIONAL { ?v rdfs:label ?name .
FILTER (STR(?name) = quot;Beerenbergquot;) }
FILTER ( ! BOUND(?name) )
Negation as Failure
}
An Introduction to SPARQL 33
34. Graph Graph Patterns
SPARQL queries are executed against an RDF dataset
●
An RDF dataset comprises:
●
One default graph and
●
Zero or more named graphs (identified by an URI)
●
Keyword GRAPH makes one of the named graphs the
●
active graph used for pattern matching
An Introduction to SPARQL 34
40. Graph Graph Patterns
dbpedia:Mount_Etna rdfs:seeAlso <http://example.org/d1>.
dbpedia:Mount_Baker rdfs:seeAlso <http://example.org/d2>.
http://example.org/d1
dbpedia:Mount_Etna
rdf:type umbel-sc:Volcano ;
rdfs:label quot;Etnaquot; .
http://example.org/d2
dbpedia:Mount_Baker
rdf:type umbel-sc:Volcano .
http://example.org/d3
dbpedia:Beerenberg
rdf:type umbel-sc:Volcano ;
rdfs:label quot;Beerenbergquot;@en .
Question: Which named graphs contain the name of a
●
volcano that is not referenced in the default graph?
An Introduction to SPARQL 40
41. Graph Graph Patterns
dbpedia:Mount_Etna rdfs:seeAlso <http://example.org/d1>.
dbpedia:Mount_Baker rdfs:seeAlso <http://example.org/d2>.
http://example.org/d1
dbpedia:Mount_Etna
rdf:type umbel-sc:Volcano ;
rdfs:label quot;Etnaquot; .
SELECT ?g WHERE {
dbpedia:Mount_Baker http://example.org/d2
GRAPH ?g { rdf:type umbel-sc:Volcano .
?v rdf:type umbel-sc:Volcano ;
http://example.org/d3
dbpedia:Beerenberg
rdfs:label ?name .
rdf:type umbel-sc:Volcano ;
}
rdfs:label quot;Beerenbergquot;@en .
OPTIONAL { ?v rdfs:seeAlso ?r }
Question: ! BOUND(?r) ) graphs contain the name of a
FILTER ( Which named
●
volcano that is not referenced in the default graph?
}
An Introduction to SPARQL 41
42. Summary – Graph Patterns
Different types of graph patterns for the query pattern
●
(WHERE clause):
Basic graph pattern (BGP)
●
Group graph pattern
●
Optional graph pattern – keyword OPTIONAL
●
Union graph pattern – keyword UNION
●
Graph graph pattern – keyword GRAPH
●
Constraints – keyword FILTER
●
An Introduction to SPARQL 42
43. Result Forms
SELECT
●
Sequence of results (i.e. sets of variable bindings)
●
Selected variables separated by space (not by comma!)
●
Asterisk (“*”) character selects all variables in the pattern
●
ASK
●
Check if there is at least one result
●
Example: Do we have volcanos that do not have a name?
●
Query
ASK WHERE { ?v rdf:type umbel-sc:Volcano .
OPTIONAL { ?v rdfs:label ?name }
FILTER( ! BOUND(?name) )
}
An Introduction to SPARQL 43
44. Result Forms
DESCRIBE
●
Returns an RDF graph with data about resources
●
Nondeterministic (i.e. query processor determines the
●
actual structure of the returned RDF graph)
Name the resource:
●
Query
DESCRIBE <http://dbpedia.org/resource/Beerenberg>
Specify the resource with a query pattern:
●
Query
DESCRIBE ?v WHERE {
?v rdf:type umbel-sc:Volcano ; rdfs:label ?name .
FILTER ( STR(?name) = quot;Beerenbergquot; ) }
Multiple variables possible or asterisk (“*”) for all
●
An Introduction to SPARQL 44
45. Result Forms
CONSTRUCT
●
Returns an RDF graph created from a template
●
Template: graph pattern with variables from the query
●
pattern
Query
CONSTRUCT { ?v rdfs:label ?name ;
rdf:type myTypes:VolcanosOutsideTheUS }
WHERE {
?v rdf:type umbel-sc:Volcano ;
rdfs:label ?name .
OPTIONAL { ?v p:location ?l
FILTER ( ?l = dbpedia:United_States ) }
FILTER ( ! BOUND(?l) )
}
An Introduction to SPARQL 45
46. Result Forms
Data
dbpedia:Mount_Etna rdf:type umbel-sc:Volcano ;
rdfs:label quot;Etnaquot; ;
p:location dbpedia:Italy .
dbpedia:Mount_Baker rdf:type umbel-sc:Volcano ;
rdfs:label quot;Mount Bakerquot; ;
p:location dbpedia:United_States .
dbpedia:Beerenberg rdf:type umbel-sc:Volcano ;
rdfs:label quot;Beerenbergquot;@en ;
p:location dbpedia:Norway .
Result
dbpedia:Mount_Etna rdfs:label quot;Etnaquot; ;
rdf:type myTypes:VolcanosOutsideTheUS.
dbpedia:Beerenberg rdf:type myTypes:VolcanosOutsideTheUS;
rdfs:label quot;Beerenbergquot;@en .
An Introduction to SPARQL 46
47. Solution Modifiers
Modify the result set, but not the single results
●
Permitted for SELECT queries only
●
DISTINCT
●
ORDER BY
●
LIMIT
●
OFFSET
●
An Introduction to SPARQL 47
48. Solution Modifiers
DISTINCT – removes duplicates from the result set
●
Data
dbpedia:Mount_Etna rdf:type umbel-sc:Volcano ;
rdfs:label quot;Etnaquot; .
dbpedia:Mount_Baker rdf:type umbel-sc:Volcano.
dbpedia:Beerenberg rdf:type umbel-sc:Volcano,
umbel-sc:NaturalElevation ;
rdfs:label quot;Beerenbergquot;@en ;
rdfs:label quot;Бееренбергquot;@ru .
?type
Query
SELECT ?type
umbel-sc:Volcano
WHERE { _:x rdf:type ?type } umbel-sc:Volcano
umbel-sc:NaturalElevation
umbel-sc:Volcano
An Introduction to SPARQL 48
49. Solution Modifiers
DISTINCT – removes duplicates from the result set
●
Data
dbpedia:Mount_Etna rdf:type umbel-sc:Volcano ;
rdfs:label quot;Etnaquot; .
dbpedia:Mount_Baker rdf:type umbel-sc:Volcano.
dbpedia:Beerenberg rdf:type umbel-sc:Volcano,
umbel-sc:NaturalElevation ;
rdfs:label quot;Beerenbergquot;@en ;
rdfs:label quot;Бееренбергquot;@ru .
?type
Query
SELECT DISTINCT ?type
umbel-sc:Volcano
WHERE { _:x rdf:type ?type } umbel-sc:NaturalElevation
An Introduction to SPARQL 49
50. Solution Modifiers
ORDER BY – orders the results
●
Query
SELECT ?v WHERE { ?v rdf:type umbel-sc:Volcano ;
rdfs:label ?name }
ORDER BY ?name
Order for different kinds of elements:
●
unbound variable < blank node < URI < literal
ASC for ascending (default) and DESC for descending
●
Hierarchical order criteria:
●
SELECT ?name WHERE { ?v rdf:type umbel-sc:Volcano ; Query
p:lastEruption ?le ;
rdfs:label ?name }
ORDER BY DESC(?le), ?name
An Introduction to SPARQL 50
51. Solution Modifiers
LIMIT – limits the number of results
●
SELECT ?name WHERE { ?v rdf:type umbel-sc:Volcano ; Query
rdfs:label ?name }
ORDER BY ?name
LIMIT 5
OFFSET – position/index of the first returned results
●
SELECT ?name WHERE { ?v rdf:type umbel-sc:Volcano ; Query
rdfs:label ?name }
ORDER BY ?name
LIMIT 5 OFFSET 10
Only useful if the order is predictable (i.e. ordered results)
●
An Introduction to SPARQL 51
52. Further Reading
W3C RDF Data Access Working Group
●
http://www.w3.org/2001/sw/DataAccess/
SPARQL Query Language for RDF
●
SPARQL Protocol for RDF
●
SPARQL Query Results XML Format
●
SPARQL interface
●
for dbpedia:
http://dbpedia.org/snorql/
An Introduction to SPARQL 52