Not logged in : Login

About: VirtTipsAndTricksSPARQL11PropertyPaths     Goto   Sponge   Distinct   Permalink

An Entity of Type : atom:Entry, within Data Space : ods.openlinksw.com associated with source document(s)

AttributesValues
type
Date Created
Date Modified
label
  • VirtTipsAndTricksSPARQL11PropertyPaths
maker
Title
  • VirtTipsAndTricksSPARQL11PropertyPaths
isDescribedUsing
has creator
content
  • %META:TOPICPARENT{name="VirtTipsAndTricksSPARQL11FeaturesExamplesCollection"}% ---+ Using SPARQL 1.1 Property Paths in Virtuoso %TOC% ---++ What are Property Paths? A property path is a possible route through a graph between two graph nodes. ---++ Why use SPARQL 1.1 Property Paths? SPARQL 1.1 Property Paths are syntactic sugar, allowing for more concise expression of some SPARQL basic graph patterns, and adding the ability to match paths of arbitrary length. They are not necessary nor required, but they can make queries shorter and easier to both write and read. ---++ How can I use SPARQL 1.1 Property Paths with Virtuoso? Here are some examples demonstrating Virtuoso's support of SPARQL 1.1 Property Paths. These example queries should work against any SPARQL endpoint that supports SPARQL 1.1 and has the ability to allow a verified user to perform INSERT operations. ---+++ Basic Usage <verbatim> ## Basic SELECT DISTINCT ?x ?name WHERE { ?x foaf:mbox <mailto:kidehen@openlinksw.com> ; foaf:knows/foaf:name ?name } </verbatim> * [[http://bit.ly/1fqlgGl][View the SPARQL Query Definition via SPARQL Protocol URL]] * [[http://bit.ly/1fql7CM][View the SPARQL Query Results via SPARQL Protocol URL]] ---+++ Usage of Sequence <verbatim> SELECT DISTINCT ?x ?name WHERE { ?x foaf:mbox <mailto:kidehen@openlinksw.com> ; foaf:knows/foaf:knows/foaf:name ?name } </verbatim> * [[http://bit.ly/1bLsYtQ][View the SPARQL Query Definition via SPARQL Protocol URL]] * [[http://bit.ly/1crUpFN][View the SPARQL Query Results via SPARQL Protocol URL]] ---+++ Usage of Inverse <verbatim> ## Mutual foaf:knows relationships: ?x knows someone who knows ?x SELECT DISTINCT ?x ?name WHERE { ?x foaf:mbox <mailto:kidehen@openlinksw.com> ; foaf:knows/^foaf:knows ?y . ?y foaf:name ?name FILTER ( ?x != ?y ) } </verbatim> * [[http://bit.ly/UmERvA][View the SPARQL Query Definition via SPARQL Protocol URL]] * [[http://bit.ly/RzOVVm][View the SPARQL Query Results via SPARQL Protocol URL]] ---+++ Usage of Negation of a Unary Operator <verbatim> SELECT DISTINCT * WHERE { ?x !rdf:type foaf:Person } LIMIT 10 </verbatim> * [[http://bit.ly/SvKQP1][View the SPARQL Query Definition via SPARQL Protocol URL]] * [[http://bit.ly/VyqogS][View the SPARQL Query Results via SPARQL Protocol URL]] ---+++ Constructing an Object using Terms from vCard, FOAF, and OWL 1 Assume the following Raw Data Representation in Turtle of a Address Book Data Object constructed using terms from the vCard vocabulary: <verbatim> <#vcardRick> <http://www.w3.org/2006/vcard/ns#given-name> "Richard" ; <http://www.w3.org/2006/vcard/ns#family-name> "Mutt" ; <http://www.w3.org/2006/vcard/ns#email> <mailto:rick@selavy.org> . <#vcardAl> <http://www.w3.org/2006/vcard/ns#given-name> "Alan" ; <http://www.w3.org/2006/vcard/ns#family-name> "Smithee" ; <http://www.w3.org/2006/vcard/ns#email> <mailto:alan@paramount.com> . </verbatim> 1 Load the sample data: <verbatim> PREFIX dc: <http://purl.org/dc/elements/1.1/> INSERT DATA { GRAPH <urn:sparql:fed:vcard:addressbook:demo> { <#vcardRick> <http://www.w3.org/2006/vcard/ns#given-name> "Richard" ; <http://www.w3.org/2006/vcard/ns#family-name> "Mutt" ; <http://www.w3.org/2006/vcard/ns#email> <mailto:rick@selavy.org> . <#vcardAl> <http://www.w3.org/2006/vcard/ns#given-name> "Alan" ; <http://www.w3.org/2006/vcard/ns#family-name> "Smithee" ; <http://www.w3.org/2006/vcard/ns#email> <mailto:alan@paramount.com> } } </verbatim> * [[http://bit.ly/14FAx04][View the SPARQL Query Definition via SPARQL Protocol URL]] * [[http://bit.ly/WQKi9i][View the SPARQL Query Results via SPARQL Protocol URL]] 1 Assume the following Raw Data Representation in Turtle of a Address Book Data Object constructed using terms from the FOAF vocabulary: <verbatim> <#foafBill> <http://xmlns.com/foaf/0.1/givenName> "Billy" ; <http://xmlns.com/foaf/0.1/familyName> "Shears" ; <http://xmlns.com/foaf/0.1/mbox> <mailto:bill@northernsongs.org> . <#foafNate> <http://xmlns.com/foaf/0.1/givenName> "Nanker" ; <http://xmlns.com/foaf/0.1/familyName> "Phelge" ; <http://xmlns.com/foaf/0.1/mbox> <mailto:nate@abkco.com> . </verbatim> 1 Load the sample data: <verbatim> PREFIX dc: <http://purl.org/dc/elements/1.1/> INSERT DATA { GRAPH <urn:sparql:fed:foaf:addressbook:demo> { <#foafBill> <http://xmlns.com/foaf/0.1/givenName> "Billy" ; <http://xmlns.com/foaf/0.1/familyName> "Shears" ; <http://xmlns.com/foaf/0.1/mbox> <mailto:bill@northernsongs.org> . <#foafNate> <http://xmlns.com/foaf/0.1/givenName> "Nanker" ; <http://xmlns.com/foaf/0.1/familyName> "Phelge" ; <http://xmlns.com/foaf/0.1/mbox> <mailto:nate@abkco.com> } } </verbatim> * [[http://bit.ly/UDTwaG][View the SPARQL Query Definition via SPARQL Protocol URL]] * [[http://bit.ly/12vEk1w][View the SPARQL Query Results via SPARQL Protocol URL]] 1 Assume the following Raw Data Representation in Turtle of a mapping oriented Data Object constructed using terms from the OWL Ontology that describe entity relationship semantics: <verbatim> # This data object is comprised of statements (triples) that map certain # properties across the vCard and FOAF vocabularies. # # These mappings express machine readable entity relationship semantics # usable by a Reasoner to produce (by inference) smart query results. <http://xmlns.com/foaf/0.1/givenName> <http://www.w3.org/2002/07/owl#equivalentProperty> <http://www.w3.org/2006/vcard/ns#given-name> . <http://xmlns.com/foaf/0.1/familyName> <http://www.w3.org/2002/07/owl#equivalentProperty> <http://www.w3.org/2006/vcard/ns#family-name> . <http://xmlns.com/foaf/0.1/mbox> <http://www.w3.org/2002/07/owl#equivalentProperty> <http://www.w3.org/2006/vcard/ns#email> . </verbatim> 1 Load the sample data: <verbatim> PREFIX dc: <http://purl.org/dc/elements/1.1/> INSERT DATA { GRAPH <urn:sparql:fed:owl:addressbook:demo> { <http://xmlns.com/foaf/0.1/givenName> <http://www.w3.org/2002/07/owl#equivalentProperty> <http://www.w3.org/2006/vcard/ns#given-name> . <http://xmlns.com/foaf/0.1/familyName> <http://www.w3.org/2002/07/owl#equivalentProperty> <http://www.w3.org/2006/vcard/ns#family-name> . <http://xmlns.com/foaf/0.1/mbox> <http://www.w3.org/2002/07/owl#equivalentProperty> <http://www.w3.org/2006/vcard/ns#email> } } </verbatim> * [[http://bit.ly/Xnawyj][View the SPARQL Query Definition via SPARQL Protocol URL]] * [[http://bit.ly/14Uvmut][View the SPARQL Query Results via SPARQL Protocol URL]] 1 Query the graphs: <verbatim> PREFIX owl: <http://www.w3.org/2002/07/owl#> SELECT bif:sprintf ( "<%s> = %s\t<%s> = %s" , str(?givenNameProp) , ?fn , str(?lastNameProp) , ?ln ) FROM <urn:sparql:fed:vcard:addressbook:demo> FROM <urn:sparql:fed:foaf:addressbook:demo> FROM <urn:sparql:fed:owl:addressbook:demo> WHERE { <http://xmlns.com/foaf/0.1/givenName> (owl:equivalentProperty|^owl:equivalentProperty)* ?givenNameProp . <http://xmlns.com/foaf/0.1/familyName> (owl:equivalentProperty|^owl:equivalentProperty)* ?lastNameProp . ?s ?givenNameProp ?fn ; ?lastNameProp ?ln } LIMIT 10 </verbatim> * [[http://bit.ly/Pw5KjO][View the SPARQL Query Definition via SPARQL Protocol URL]] * [[http://bit.ly/1hnpbRY][View the SPARQL Query Results via SPARQL Protocol URL]] ---++ Related * [[http://www.w3.org/TR/sparql11-property-paths/][W3 documentation of SPARQL 1.1. Property Paths]] * [[VirtTipsAndTricksGuide][Virtuoso Tips and Tricks Collection]] * [[VirtTipsAndTricksSPARQL11FeaturesExamplesCollection][Examples of SPARQL 1.1 Feature Usage in Virtuoso]] * [[http://virtuoso.openlinksw.com/tutorials/sparql/SPARQL_Tutorials_Part_9/SPARQL_Tutorials_Part_9.html][Virtuoso SPARQL 1.1 Syntax Tutorial]] * [[http://docs.openlinksw.com/virtuoso/rdfsparql.html][Virtuoso Documentation]]
id
  • cd69334bac6624d4aca6c07eeb8c7564
link
has container
http://rdfs.org/si...ices#has_services
atom:title
  • VirtTipsAndTricksSPARQL11PropertyPaths
links to
atom:source
atom:author
atom:published
  • 2017-06-13T05:45:53Z
atom:updated
  • 2017-06-13T05:45:53Z
topic
is made of
is container of of
is link of
is http://rdfs.org/si...vices#services_of of
is creator of of
is atom:entry of
is atom:contains of
Faceted Search & Find service v1.17_git150 as of Jan 20 2025


Alternative Linked Data Documents: iSPARQL | ODE     Content Formats:   [cxml] [csv]     RDF   [text] [turtle] [ld+json] [rdf+json] [rdf+xml]     ODATA   [atom+xml] [odata+json]     Microdata   [microdata+json] [html]    About   
This material is Open Knowledge   W3C Semantic Web Technology [RDF Data] Valid XHTML + RDFa
OpenLink Virtuoso version 08.03.3332 as of Sep 11 2024, on Linux (x86_64-generic-linux-glibc25), Single-Server Edition (15 GB total memory, 772 MB memory in use)
Data on this page belongs to its respective rights holders.
Virtuoso Faceted Browser Copyright © 2009-2025 OpenLink Software