DOC PREVIEW
UTD CS 6375 - SPARQL - Part 1

This preview shows page 1-2-16-17-18-33-34 out of 34 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 34 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 34 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 34 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 34 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 34 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 34 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 34 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 34 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Slide 1Slide 2SPARQLSPARQLSlide 5IntroductionIntroductionConventionsConventionsConventionsConventionsSlide 12Writing Simple QueriesWriting Simple QueriesWriting Simple QueriesWriting Simple QueriesWriting Simple QueriesExampleExampleMatching RDF LiteralsMatching RDF LiteralsMatching RDF LiteralsMatching RDF LiteralsExampleBlank Node Labels in Query ResultsBlank Node Labels in Query ResultsExampleExampleBuilding RDF GraphsSlide 30RDF Term ConstraintsRestricting the Values of StringsRestricting Numeric ValuesOther Term ConstraintsSPARQL (Part 1)All slides are adapted from the W3C RecommendationSPARQL Query Language for RDFWeb link: http://www.w3.org/TR/rdf-sparql-query/Overview•RDF is a directed, labeled graph representation of the information on the Web•SPARQL expresses queries across multiple and highly heterogeneous data sources that contain RDF•SPARQL is used for querying the graphs for patternsSPARQL•SPARQL also supports extensible value testing and constraining queries by source RDF graph •SPARQL results are result sets or RDF graphsSPARQL1. Introduction•RDF is a data representation language for the information on the Web•RDF is used to represent diverse information such as social networks, information about people etc•Another feature of RDF is that it can be used to merge these ' islands' of diverse data•SPARQL is a language designed to query RDFIntroduction•SPARQL is designed to meet the requirements identified by the RDF Data Access Working Group•SPARQL also relates to –SPARQL Protocol for RDF [SPROT] – remote protocol for issuing SPARQL queries and receiving results–SPARQL Query Results XML Format [RESULTS] – defines an XML format for representing results of SPARQL SELECT and ASK queries Introduction•Namespaces Prefix IRI rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns# rdfs: http://www.w3.org/2000/01/rdf-schema# xsd: http://www.w3.org/2001/XMLSchema# fn: http://www.w3.org/2005/xpath-functions#Conventions•Data Description–We use the TURTLE format for triples, this allows the use of prefixes in IRI's@prefix dc: <http://purl.org/dc/elements/1.1/> .@prefix : <http://example.org/book/> .:book1 dc:title "SPARQL Tutorial" .Conventions•Result Descriptions–All results are represented in tabular form–We define the use of a binding which is an association between a variable and the RDF term–In the example above, the variable ’x’ is bound to the RDF term ’Alice', the variable ’y’ is bound to the RDF ’http://example/a’ and the variable ’z’ is not bound to any RDF term Conventions<http://example/a>“Alice”zyx•Terminology used–IRI’s (Internationalized Resource Identifier)–Literals–Lexical form–Plain literal–Language tag–Typed Literal–Datatype IRI–Blank nodeConventions2. Writing Simple Queries•The most basic form of a SPARQL query is the basic graph pattern which is nothing but a set of triples where each of the subject, predicate or object may be a variable•We find a match of the basic graph pattern in the given subgraph when RDF terms in a subgraph match the variables in the query resulting in a RDF graph that matches the given subgraphWriting Simple Queries•A simple example–Data (one triple)<http://example.org/book/book1> <http://purl.org/dc/elements/1.1/title> "SPARQL Tutorial" .–QuerySELECT ?titleWHERE { <http://example.org/book/book1> <http://purl.org/dc/elements/1.1/title> ?title .}–ResultWriting Simple Queries“SPARQL Tutorial”title•A simple example–We see that the given data graph contains the URI for a book with a predicate identifying the title of the book–The SPARQL query consists of the SELECT clause that identifies the variables that should appear in the query result and the WHERE clause that identifies the basic graph pattern that should be used to match against the data graph–In the above example the basic graph pattern consists of a simple triple pattern with a variable for the object Writing Simple Queries•An example with multiple matching results–Data@prefix foaf: <http://xmlns.com/foaf/0.1/> ._:a foaf:name "Johnny Lee Outlaw" ._:a foaf:mbox <mailto:[email protected]> ._:b foaf:name "Peter Goodguy" ._:b foaf:mbox <mailto:[email protected]> ._:c foaf:mbox <mailto:[email protected]> .–QueryPREFIX foaf: http://xmlns.com/foaf/0.1/SELECT ?name ?mboxWHERE { ?x foaf:name ?name . ?x foaf:mbox ?mbox}Writing Simple Queries•An example with multiple matching results–Results–The query result may have 0, 1, or many solutions–Each solution gives one way to match the basic graph pattern against the data, in the above example there are two ways to bind variables to the RDF terms_:a foaf:name "Johnny Lee Outlaw" . _:a foaf:box <mailto:[email protected]> . _:b foaf:name "Peter Goodguy" . _:b foaf:box <mailto:[email protected]> .Writing Simple Queries<mailto:[email protected]>“Peter Goodguy”<mailto:[email protected]>“Johnny Lee Outlaw”mboxnameA query to select objects given any subject and a property based on some PREFIXPREFIX info: <http://somewhere/peopleInfo#> SELECT ?z WHERE { ?element info:age ?z . }ExampleNote: End of Lines are essentially a space, so SPARQL can all be one or more lines.A query to select objects based on a “join” conditionPREFIX vCard: <http://www.w3.org/2001/vcard-rdf/3.0#> SELECT ?x ?z WHERE{ ?element vCard:Family ?x .?element vCard:Given ?z . } ExampleConsider the data below:@prefix dt: <http://example.org/datatype#> @prefix ns: <http://example.org/ns#>@prefix : <http://example.org/ns#>@prefix xsd: <http://www.w3.org/2001/XMLSchema#>:x ns:p "cat"@en .:y ns:p "42"^^xsd:integer .:z ns:p "abc"^^dt:specialDatatype .–Note that, in Turtle, "cat"@en is an RDF literal with a lexical form "cat" and a language en; "42"^^xsd:integer is a typed literal with the datatype http://www.w3.org/2001/XMLSchema#integer;and "abc"^^dt:specialDatatype is a typed literal with the datatype http://example.org/datatype#specialDatatype.Matching RDF Literals•Matching Literals with language tags–Language tags are expressed using @ and the language tag–The following query has no solution because “cat” is not the same as “cat”@en–QuerySELECT ?v


View Full Document

UTD CS 6375 - SPARQL - Part 1

Download SPARQL - Part 1
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view SPARQL - Part 1 and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view SPARQL - Part 1 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?