1 / 21

SPARQL All slides are adapted from the W3C Recommendation SPARQL Query Language for RDF

SPARQL All slides are adapted from the W3C Recommendation SPARQL Query Language for RDF Web link: http://www.w3.org/TR/rdf-sparql-query/. 5. Named Graphs. Named Graphs. Every SPARQL query runs against: At least the default graph One or more named graphs

doris
Télécharger la présentation

SPARQL All slides are adapted from the W3C Recommendation SPARQL Query Language for RDF

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. SPARQL All slides are adapted from the W3C Recommendation SPARQL Query Language for RDF Web link: http://www.w3.org/TR/rdf-sparql-query/

  2. 5. Named Graphs

  3. Named Graphs Every SPARQL query runs against: At least the default graph One or more named graphs Or merged set of default and all named graphs *Derived from http://www.w3.org/TR/rdf-sparql-query -Section 8.2

  4. Named Graph Concepts Set of triples with an identifier No relation required to URIs in the set Identifier must be IRI Generally URI with no spaces (and some other characters) Name/IRI can (obviously) also be a URI Often associated with concept of a file i.e. graph in a file Not a required structure A triple may be in any number of graphs If file-based, then appearing in multiple files In a persistent store, triple is likely replicated with a different graph identifier with each copy

  5. Named Graph Aggregation Graphs at a single SPARQL endpoint Endpoints may aggregate as they see fit May query other/remote SPARQL endpoints for knowledge May provide whatever graph name they wish SPARQL does not define the mechanism that requests aggregation of multiple endpoints Nor does it define whether or not they are considered a named graph SPARQL allows selection of graphs based on their name (within the local system)

  6. SPARQL Named Graph Keywords FROM contains an IRI that indicates a graph to be used to form the default graph In this case, the named graph lose its identity in the query FROM NAMED provide a named graph in the RDF Dataset The name of the graph can be part of the query If no FROM clause, then default graph is empty GRAPH For the WHERE clause to specify or find out the graph name fulfilling a query

  7. Simple Annotated Example PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX dc: <http://purl.org/dc/elements/1.1/> SELECT ?who ?g ?mbox FROM <http://example.org/dft.ttl> FROM NAMED <http://example.org/alice> FROM NAMED <http://example.org/bob> WHERE { ?g dc:publisher ?who . GRAPH ?g { ?x foaf:mbox ?mbox } } Replace default graph with dft.ttl Add two named graphs to the set of graphs Find who published the graph* Find graphs using the mbox property. *The default graph has no identifier (so is never the answer).

  8. Usage Query Effects

  9. Example Using GRAPH for Restriction PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX data: <http://example.org/foaf/> SELECT ?nick FROM NAMED <http://example.org/foaf/aliceFoaf> FROM NAMED <http://example.org/foaf/bobFoaf> WHERE { GRAPH data:bobFoaf { ?x foaf:mbox <mailto:bob@work.example> . ?x foaf:nick ?nick } } Only query bobFoaf for this info*. *The default graph has no identifier (so it is never the restriction).

  10. 6. Unsupported Functionality

  11. Data Modification Some proposed standards, but generally considered a bad idea Proposals SPARQL Update SPARUL or SPARQL+ Adds CREATE DELETE, DROP, and INSERT

  12. Subqueries No specific subquery support, but does support nested subgraphs in a query Subquery Nested SELECT within a WHERE Nested subgraphs Can nest graph patterns inside other graph patterns

  13. Aggregation No count, min, max, avg, or sum SPARQL+ proposes such Full list of SPARQL issues maintained: http://www.w3.org/2001/sw/DataAccess/issues

  14. 7. Other Features

  15. Other Query Forms ASK Test whether or not a query pattern has a solution Just returns whether or not a solution exists PREFIX foaf: <http://xmlns.com/foaf/0.1/>/ ASK { ?x foaf:name "Alice" ; foaf:mbox <mailto:alice@work.example> } -> true / false (in XML form)

  16. Other Query Forms DESCRIBE returns a single result RDF graph (i.e. tripes file) containing RDF data about resources The SPARQL service decides how much/what to return (whatever the service providers considers to be useful) PREFIX foaf: <http://xmlns.com/foaf/0.1/> DESCRIBE ?x ?y <http://example.org/> WHERE {?x foaf:knows ?y}

  17. Sorting PREFIX table: <http://www.daml.org/2003/01/periodictable/PeriodicTable#> SELECT ?name WHERE { ?element table:name ?name; table:atomicWeight ?weight. } ORDER BY DESC(?weight) LIMIT 10 OFFSET 10

  18. 7. Summary Features Summarized from: http://thefigtrees.net/lee/sw/sparql-faq

  19. SPARQL Benefits Implicit join syntax Does not require explicit joins that specify the relationship between differently structured data All relationships are of a fixed size Data lives in a single graph Strong support for querying semi-structured and ragged data i.e. data with an unpredictable and unreliable structure Variables may occur in the predicate position to query unknown relationships OPTIONAL keyword provides support for querying relationships that may or may not occur in the data (a la SQL left joins)

  20. More SPARQL Benefits Query disparate data sources (not sharing a single native representation) in a single query Join heterogeneous data at a higher level than that of the native structure of the data Mappings can be performed on the fly Overcomes the different structures used by different database vendors! Query in a networked, web environment Pairing of a default graph and zero or more named graphs SPARQL endpoint may join information from multiple data sources accessible across different Web sites Can use NAMED or NAMED GRAPH to indicate remote graphs to include

  21. SPARQL Drawbacks Relatively Young At least compared to XPath or SQL Immature Query optimization still a research topic Lack of support for transitive/ hierarchical queries Really for known/explicit levels or hierarchy

More Related