sparql - Import RDF data in SQL? -


i quite comfortable using sql having impossible time understanding sparql. starters, don't understand how @ structure of data (in mysql describe <table name>) can query appropriate fields.

is there way me import entire rdf dataset respective tables in mysql database?

barring that, there way select * all tables (or whatever equivalent descriptor is) such can output data csv (and take there?)

the rdf dataset trying query has sparql endpoint , guide on how sparql having hard time understanding it.

for example:

prefix meannot: <http://rdf.myexperiment.org/ontologies/annotations/> prefix sioc: <http://rdfs.org/sioc/ns#> prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> prefix mebase: <http://rdf.myexperiment.org/ontologies/base/> select distinct ?annotator_name {   ?comment mebase:annotates <http://www.myexperiment.org/workflows/52> .   ?comment rdf:type meannot:comment .   ?comment mebase:has-annotator ?annotator   ?annotator sioc:name ?annotator_name } 

makes little sense me. why there period @ end of of statements not others? , ?comment mebase:has-annotator ?annotator mean in plain english? select annotators name annotators name annotators name? huh?

i grateful resources point me to.

although sparql looks sql in syntax how functions quite different problem , many others have when trying learn it.

pattern matching

sparql triple pattern matching rather selecting tables sql. each set of 3 items in example represents triple pattern. example:

?comment rdf:type meannot:comment . 

this tells sparql processor find thing has rdf:type of meannot:comment i.e. things of type comment. in pattern ?comment variable acts wildcard, think of field in sql can select

if add in additional triple pattern uses variable asking sparql processor find things match triple patterns, so:

?comment mebase:annotates <http://www.myexperiment.org/workflows/52> . ?comment rdf:type meannot:comment . 

this finds things comments on specific item.
in sql terms writing select commentid comments itemid=1234 if helps understand it.

as start adding in additional variables can think of doing joins other tables:

?comment mebase:annotates <http://www.myexperiment.org/workflows/52> . ?comment rdf:type meannot:comment . ?comment mebase:has-annotator ?annotator . 

this finds things comments , users made them on specific item
equivalent select commentid, userid comments c inner join users u on c.userid=u.userid itemid=1234 in sql

syntax notes

as far syntax goes . denotes end of triple pattern.
fact omitted in example error on part of people publishing how guide. happen work in 1 of universities involved in project have dropped colleague note asking them fix this.

what may see in examples use of ; @ end of triple pattern. these shorthands repeating subject e.g.

?comment mebase:annotates <http://www.myexperiment.org/workflows/52> ;          rdf:type meannot:comment . 

means don't have type out ?comment again subsequent pattern.

similarily , used repeat subject , predicate:

?comment rdf:type meannot:comment , ex:annotation . 

would mean ?comment , rdf:type repeated, in plain english above things of type comment , of type annotation

discovering data structure

rdf not stored in tables since schemaless data model, closest thing tables named graphs way logically group sets of triples together.

take @ question on exploratory sparql queries suggestions on queries try.

if want select can select * { ?s ?p ?o } - beware many endpoints impose limit on number of results 1 query if endpoint has millions of triples behind may few thousand back. can page through results using limit , offset e.g.

select * { ?s ?p ?o } limit 1000 offset 0 select * { ?s ?p ?o } limit 1000 offset 1000 select * { ?s ?p ?o } limit 1000 offset 2000 # , forth until find no further results 

if want data trawl through try looking around on site see if offer rdf dump typically zipped archive bunch of rdf files in it. let @ data locally

putting rdf sql tables

there systems let store rdf in sql based databases take who's worked large variety of triple stores near performant using native triple store.

you may interested in r2rml new w3c standard (currently in working draft) defines standard way map relational data rdf. of documentation may better understand relationship between rdf/sparql , sql

tutorials

for fuller tutorial i'd check out sparql example 1 of authors of sparql specification , highly recommended


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -