Mais conteúdo relacionado Semelhante a NoSQL and Triple Stores (20) NoSQL and Triple Stores16. RDF “ Ant in Action” title creator Author “ Steve Loughran” name “ 193239480X ” ISBN10 creator Author “ Erik Hatcher” name http://webbooks/b4598 17. RDF “ Ant in Action” title creator Author “ Steve Loughran” name “ 193239480X ” ISBN10 creator Author “ Erik Hatcher” name shop Stock item item $49.99 price ref http://webbooks/b4598 18. RDF “ Ant in Action” title creator Author “ Steve Loughran” name “ 193239480X ” ISBN10 creator Author “ Erik Hatcher” name shop Stock item “ good” item $49.99 price ref creator rating “ Andy Seaborne” http://review.org/review57 http://webbooks/b4598 19. Turtle @prefix : <http://example.org/> . @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . @prefix foaf: <http://xmlns.com/foaf/0.1/> . :Andy a foaf:Person ; foaf:name "Andy Seaborne" ; foaf:mbox <mailto:andy@apache.org> ; foaf:knows :Paolo ; foaf:knows :Steve . :Paolo a foaf:Person ; foaf:name "Paolo Castagna" ; foaf:mbox <mailto:castagna@apache.org> . :Steve foaf:name "Steve Loughran" ; foaf:mbox_sha1 "0678d36518d039a64ee4baba0a568afe535ce5f3" . 20. RDF RDF is a graph Your computer thinks of this is as a logical table (but probably stores it differently) Subject Predicate Object 21. A SPARQL Query Looks Like … @prefix person: <http://example/person/> . @prefix foaf: <http://xmlns.com/foaf/0.1/> . person:A foaf:name "Alice" . person:A foaf:mbox <mailto:alice@example.net> . person:B foaf:name "Bob" . PREFIX person: <http://example/person/> PREFIX foaf: <http://xmlns.com/foaf/0.1/> SELECT ?name WHERE { ?person foaf:mbox <mailto:alice@example.net> . ?person foaf:name ?name . } ----------- | name | =========== | "Alice" | ----------- 22. A SPARQL Query Looks Like … @prefix dc: <http://purl.org/dc/elements/1.1/> . @prefix stock: <http://example.org/stock#> . stock:book1 dc:title "SPARQL Query Language Tutorial" . stock:book2 dc:title "SPARQL Query Language (2nd ed)" . stock:book3 dc:title "Moving from SQL to SPARQL" . stock:book4 dc:title "Applying XQuery" . PREFIX dc: <http://purl.org/dc/elements/1.1/> PREFIX stock: <http://example.org/stock#> SELECT ?book ?title { ?book dc:title ?title . FILTER (regex(?title , " SPARQL " )) } -------------------------------------------------- | book | title | ================================================== | stock:book3 | "Moving from SQL to SPARQL" | | stock:book2 | "SPARQL Query Language (2nd ed)" | | stock:book1 | "SPARQL Query Language Tutorial" | -------------------------------------------------- 23. SPARQL: All people who know 3 others PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX foaf: <http://xmlns.com/foaf/0.1/> SELECT ?name { { SELECT ?x (count(*) AS ?count) { ?x foaf:knows ?y . } GROUP BY ?x HAVING (?count = 3) } ?x foaf:name ?name . } 24. SPARQL Protocol GET /foo/sparql?query=SELECT (Count(*) AS ?c) { ?s ?p ?o } Accept: application/sparq-results+json GET /foo/sparql?query=SELECT%20%28Count%28%2A%29%20AS%20%3Fc%29%20{%20%3Fs%20%3Fp%20%3Fo%20} { "head": { "vars": [ "c" ] } , "results": { "bindings": [ { "c": { "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "type": "typed-literal" , "value": "10" } } ] } } 29. RESTful operation PUT /store?graph=http%3A//example/g1 HTTP/1.1 Host: server.com Content-type: application/rdf+xml <?xml version='1.0' encoding='UTF-8'?> <rdf:RDF xmlns:rdf='...'> ... </rdf:RDF>