NoSQL and Triple Stores

Embed Size (px)

Citation preview

NoSQL and Triple Stores
Andy Seaborne

NoSQL

From http://nosql-database.org/

Graph Databases

Key-Value stores

Column Stores

Document Stores

Triples Stores

NoSQL

Non-relational

Distributed

Open-source

horizontally scalable

Schema-free

easy replication support

simple API

eventually consistent / BASE (not ACID)

a huge data amount

From http://nosql-database.org/

Triple Stores

Data Model: RDFSubject-predicate-object

Don't store triplesthey store named sets of triples

Schema-lessDump and run data management

SPARQLQuery Language

Protocol using HTTP

RDF

Ant in Action

title

creatorAuthor

Steve Loughranname

193239480XISBN10

creatorAuthor

Erik Hatchernamehttp://webbooks/b4598

RDF

Ant in Action

title

creatorAuthor

Steve Loughranname

193239480XISBN10

creatorAuthor

Erik HatchernameshopStock item

item

$49.99pricerefhttp://webbooks/b4598

RDF

Ant in Action

title

creatorAuthor

Steve Loughranname

193239480XISBN10

creatorAuthor

Erik HatchernameshopStock item

gooditem

$49.99pricerefcreatorrating

Andy Seabornehttp://review.org/review57http://webbooks/b4598

Turtle

@prefix : .@prefix rdf: .@prefix foaf: .

:Andy a foaf:Person ; foaf:name "Andy Seaborne" ; foaf:mbox ; foaf:knows :Paolo ; foaf:knows :Steve .

:Paolo a foaf:Person ; foaf:name "Paolo Castagna" ; foaf:mbox .

:Steve foaf:name "Steve Loughran" ; foaf:mbox_sha1 "0678d36518d039a64ee4baba0a568afe535ce5f3" .

RDF

RDF is a graph

Your computer thinks of this is as a logical table (but probably stores it differently)

SubjectPredicateObject

A SPARQL Query Looks Like

@prefix person: .@prefix foaf: .

person:A foaf:name "Alice" .person:A foaf:mbox .person:B foaf:name "Bob" . PREFIX person: PREFIX foaf:

SELECT ?name
WHERE
{ ?person foaf:mbox . ?person foaf:name ?name . } -----------| name |===========| "Alice" |-----------

@prefix dc: .@prefix 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: PREFIX 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" |--------------------------------------------------A SPARQL Query Looks Like

SPARQL: All people who know 3 others

PREFIX rdf: PREFIX foaf:

SELECT ?name{ { SELECT ?x (count(*) AS ?count) { ?x foaf:knows ?y . } GROUP BY ?x HAVING (?count = 3) } ?x foaf:name ?name .}

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" } } ] }}

SPARQL Graph Store Protocol

Simple way to manage a store

GET, PUT, POST, DELETE

NamingSame server
http://server/store/graph1

Different server
http://server/store?graph=http://example/g1
http://server/store?graph=http%3A//example/g1


RESTful operation

PUT /store?graph=http%3A//example/g1 HTTP/1.1Host: server.comContent-type: application/rdf+xml

...

Triples Store as NoSQL

Mostly open source

Some distributed

API Not proprietary

Looks like SQL

Eventual consistency

Huge amount of data?Garlik: 20 Billion triples (cluster, ~20 machines)

AllegroGraph: 1 Trillion (single, very large machine)

08/09/11