• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
RDF Tutorial - SPARQL 20091031
 

RDF Tutorial - SPARQL 20091031

on

  • 7,510 views

RDF Tutorial - SPARQL

RDF Tutorial - SPARQL

http://www.onoffmix.com/e/sonagi/1116

Statistics

Views

Total Views
7,510
Views on SlideShare
6,710
Embed Views
800

Actions

Likes
5
Downloads
272
Comments
1

13 Embeds 800

http://samples.tistory.com 413
http://kwangsub.blogspot.com 163
http://kwangsub.blogspot.kr 81
http://blog.kwangsub.pe.kr 68
http://kiminitodoke-bee.blogspot.com 45
http://www.slideshare.net 16
http://doremi.konantech.com 5
http://psuns.com 3
http://translate.googleusercontent.com 2
http://webcache.googleusercontent.com 1
http://kwangsub.blogspot.jp 1
http://www.slashdocs.com 1
http://kwangsub.blogspot.co.uk 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel

11 of 1 previous next

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    RDF Tutorial - SPARQL 20091031 RDF Tutorial - SPARQL 20091031 Presentation Transcript

    • SPARQL NHN kwangsub.kim@gmail.com RDF Tutorial 2009. 10. 31
    • RDF ! SPARQL ! PLAY ! SPARQL 1.1 !
    • http://delicious.com/kwangsub.kim/bundle:RDFTutorial2009 http://vocamp.org/wiki/VoCampSeoul2009#Slides http://delicious.com/kwangsub.kim/%23VoCampSeoul2009
    • RDF Resource Description Framework ( ) ! ! Subject - Predicate - Object ! , (RSS) , (FOAF) ...
    • Graph ? SPARQL <sparql ...> <head> <variable name="x"/> <variable name="mbox"/> </head> <results> <result> <binding name="x"> <bnode>r2</bnode> </binding> <binding name="mbox"> <uri>mailto:bob@work.example.org</uri> </binding> </result> </results> </sparql>
    • 2008-07-16 ... *http://pingthesemanticweb.com
    • 2008-11-04 ... *http://pingthesemanticweb.com
    • 2009-01-08 ... *http://pingthesemanticweb.com
    • 2008-07-16 2009-10-31 2008-11-04 2009-01-08 200% 200% 4,955,878 16,705,060 7,504,227 8,826,082 *http://pingthesemanticweb.com
    • GRDDL SPARQL
    • SPARQL Simple Protocol And RDF Query Language is a query language and a protocol for accessing RDF <sparql ...> Simple Protocol <head> <variable name="x"/> <variable name="mbox"/> </head> http://semantic.lab.naver.com/rdf/endpoint/sparql?select.... <results> <result> <binding name="x"> SELECT ?email <bnode>r2</bnode> WHERE { </binding> <binding name="mbox"> ?user :email ?email. <uri>mailto:bob@work.exampl ?user :name “ ”; </binding> & } </result> </results> </sparql> RDF Query Language Graph SPO (Subject, Predicate, Object) Query Language Pattern Match
    • SPA RDF Query Language
    • Query Language
    • SQL vs. SPARQL Return Variables SELECT name SELECT ?name FROM users WHERE { WHERE contact=‘011-201-0000’; ?user rdf:type :User. ?user :name ?name. ?user :contact “011-201-0000”. SPO Pattern } FROM <http://semantic/users.rdf> Graph Source
    • Graph > Query Language > Binding > Protocol rdf:type SELECT ?name _person foaf:Person WHERE { :contact ?user rdf:type foaf:Person. “011-201-0000” :name ?user :contact “011-201-0000”. ?user :name ?name. } <http://semantic/users.rdf> FROM <http://semantic/users.rdf> <sparql xmlns=”http://www.w3.org...”> <head> <variable name="name"/> </head> ?name = “ ” <results> <result> <binding name="name"> <literal> </literal> </binding> </result> </results> </sparql>
    • SPARQL BASE <http://example.org/> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX ex: <properties/1.0#> SELECT DISTINCT $person ?name $age FROM <http://rdf.example.org/personA.rdf> FROM <http://rdf.example.org/personB.rdf> WHERE { $person a foaf:Person ; foaf:name ?name. OPTIONAL { $person ex:age $age } . FILTER (!REGEX(?name, “Bob”)) } ORDER BY ASC(?name) LIMIT 10 OFFSET 20 * SPARQL RDF Query Language Reference v1.8 by Dave Beckett.
    • Terms Sytax Pattern
    • Terms IRI : URI reference within an RDF graph <http://www.w3.org> <http://semantic.naver.com/#Movie> <abc.rdf> //base URI foaf:name //prefix URI , PREFIX #x00 (X) //UNICODE Datatype IRI : datatype URI <http://www.w3.org/2001/XMLSchema#string> <http://www.w3.org/2001/XMLSchema#integer> Plain Literal : lexical form, optionally language tag, @ko “Semantic web” , “ ”@ko Typed Literal : lexical form, datatype URI “30”^^xsd:integer “kwangsub”^^http://www.w3.org/2001/XMLSchema#string Blank node : dummy node, node , _:a, _n06968595988
    • Terms NameSpace :Vocabulary URI http://www.w3.org/1999/02/22-rdf-syntax-ns# http://purl.org/dc/elements/1.1/ http://xmlns.com/foaf/0.1/ Prefix : URI rdf, dc, foaf RDF Graph : A Set of RDF Triples RDF Triple : S-P-O Subject : IRI or Blank Node Predicate : IRI Object : IRI or Blank Node or Literal
    • Terms Match : Graph SPO Query Pattern Match Solutions : Match ?x = “ ” Query Variable : Solutions ?x or $name
    • Play # “ ” “email” ? :email _person kwangsub.kim@gmail.com :name SELECT ?email WHERE { ?person :email ?email. ?person :name “ ”; }
    • Syntax - RDF Term Syntax Literals “Hi Korea” //”Hi Korea” “Hi Korea”@en // “Hi Korea”^^xsd:string // etc. integer, boolean 1 == “1”^^xsd:integer true == “true”^^xsd:boolean 1.3 == “1.3”^^xsd:decimal
    • Play # kwangsub email ? :email _person kwangsub.kim@gmail.com :name kwangsub@en SELECT ?email WHERE { ?person :name “kwangsub”@en. ?person :email ?email. }
    • Syntax - RDF Term Syntax IRI <http://example.org/book/book1> BASE <http://example.org/book/> <book1> PREFIX book: <http://example.org/book/> book:book1
    • Syntax -Triple Pattern Syntax PREFIX, BASE PREFIX dc: <http://purl.org/dc/elements/purl.org/> SELECT ?title WHERE { <http://example.org/book/book> dc:title ?title } PREFIX dc: <http://purl.org/dc/elements/1.1/> PREFIX : <http://example.org/book/> SELECT $title WHERE { :book1 dc:title $title } BASE <http://example.org/book/> PREFIX dc: <http://purl.org/dc/elements/1.1/> SELECT $title WHERE { <book1> dc:title $title }
    • Play # kwangsub email ? :like _person book:book_3 :name book:name kwangsub@en BASE <http://RDFTutorial.net/2009/> PREFIX book: <http://example.org/book/> SELECT ?book_name WHERE { ?person :like book:book_3. book:book_3 book:name ?book_name. }
    • Syntax - RDF Term Syntax Query Var ?var or $var Blank [ :p “v”]. == [] :p “v”. Unique Blank - IRI _b57 :p “v”. // [ foaf:name ?name ; foaf:mbox <mailto:ss@c.com>] // _b11 foaf:name ?name ; S PO . _b11 foaf:mbox <mailto:ss@c.com>
    • Play .# foaf:name kwangsub.kim name? _a :love _b :name foaf:name kwangsub.kim soomers PREFIX foaf: <http://xmlns.com/foaf/0.1/>. PREFIX : <http://RDFTutorial.net/2009/>. SELECT $name WHERE { ?_a foaf:name “kwangsub.kim”. ?_a :love $_b. $_b <http://RDFTutorial.net/2009/name> $name. }
    • Syntax ; , ;, ?people foaf:name ?name ; foaf:mbox ?mbox . ~ ?people foaf:name ?name . ?people foaf:mbox ?mbox . ?people foaf:nick "Alice" , "Alice_" . ~ ?people foaf:nick "Alice" . ?people foaf:nick "Alice_" .
    • Play # kwangsub “ ” ? foaf:knows _a _b foaf:nickname foaf:name foaf:name kwangsub SangWon PREFIX foaf: <http://xmlns.com/foaf/0.1/>. SELECT ?name WHERE { ?_a foaf:nickname “ ”; foaf:name “kwangsub”. ?_a foaf:knows ?_b. ?_b foaf:name ?name. }
    • Pattern Basic Graph Pattern {?people foaf:name "kwangsub".} Group Graph Pattern { {?people foaf:name "kwangsub".} {?people foaf:email "kwangsub.kim@gmail.com".} } // Filter { ?people foaf:name ?name. FILTER regex (?name, “kw”) }
    • Pattern Optional Graph Pattern _:a rdf:type foaf:Person . _:a foaf:name "Alice" . _:a foaf:mbox <mailto:alice@example.com> . _:a foaf:mbox <mailto:alice@work.example> . _:b rdf:type foaf:Person . _:b foaf:name "Bob" . SELECT ?name ?mbox WHERE { ?people foaf:name ?name . OPTIONAL { ?people foaf:mbox ?mbox } }
    • Pattern Optional Graph Pattern + FILTER SELECT ?people ?mbox WHERE { ?people foaf:name ?name . OPTIONAL { ?people foaf:mbox ?mbox . FILTER regex(?mbox, “@gmail”)} } //OPTIONAL Alternative Graph Pattern SELECT ?people ?mbox WHERE { {?people foaf:name ?name .} UNION {?people naver:name ?name .} }//UNON {?people foaf:name ?name . ?people foaf:knows ?name} UNION {? people naver:name ?name. ?people naver:knows ?name}
    • Constraint String Value Constraint SELECT ?people, ?name WHERE { ?people :name ?name FILTER regex(?name, “^kwan”, “i”) } //kwan Numeric Value Constraint SELECT ?people, ?age WHERE { ?people :age ?age. FILTER (?age > 30) } //30
    • Play # 35 35 ? foaf:knows _a _b :age foaf:name :age foaf:name 36 Dongbum 35 Haklae PREFIX foaf: <http://xmlns.com/foaf/0.1/>. PREFIX : <http://RDFTutorial.net/2009/>. SELECT ?name WHERE { ?_a :age ?age. ?_a :age ?age. FILTER ( ?age >= 35 ) ?_a foaf:knows ?_b. ?_a foaf:knows ?_b. ?_b :age ?b_age; ?_b :age ?b_age; foaf:name ?name. foaf:name ?name. FILTER ( ?age >= 35 ) FILTER ( ?b_age <= 35) FILTER ( ?b_age <= 35) }
    • Solution Sequences and Modifiers Order SELECT ?people, ?name WHERE { ?people :name ?name } ORDER BY ?name // A-Z, DESC(?name) SELECT ?s ?p ?o WHERE { ?s ?p ?o } // SPO ORDER BY ?o // ???
    • Play # ? _d _b _a _c :age :age :age :age 45 33 21 26 PREFIX : <http://RDFTutorial.net/2009/>. SELECT ?user WHERE { ?user :age ?age. } ORDER BY ?age.
    • Solution Sequences and Modifiers Offset SELECT ?s ?p ?o WHERE { ?s ?p ?o. } OFFSET 10 //11 solutions LIMIT SELECT ?s ?p ?o SELECT ?s ?p ?o WHERE { WHERE { ?s ?p ?o. ?s ?p ?o. } } LIMIT 10 //10 solutions LIMIT 5 OFFSET 10 //
    • Play # , 2 ? _d _b _a _c :age :age :age :age 45 33 21 26 PREFIX : <http://RDFTutorial.net/2009/>. SELECT ?user WHERE { ?user :age ?age. } ORDER BY ?age. LIMIT 2 .
    • Query Form ASK PREFIX foaf: <http://xmlns.com/foaf/0.1/> ASK { ?x foaf:name "Alice"; :age ?age. FILTER ( ?age > 20) } DESCRIBE PREFIX ent: <http://org.example.com/employees#> DESCRIBE ?x WHERE { ?x ent:employeeId "1234" }
    • Simple Protocol ARQL
    • Simple Protocol & RDF Endpoint HTTP SOAP ... Endpoint
    • Simple Protocol * HTTP Binding * SOAP Binding Request GET /sparql/?query=EncodedQuery HTTP/1.1 Host: www.example User-agent: my-sparql-client/0.1 Response <sparql ...> <head> <variable name="x"/> <variable name="mbox"/> </head> <results> <result> <binding name="x"> <bnode>r2</bnode> </binding> <binding name="mbox"> <uri>mailto:bob@work.example.org</uri> </binding> </result> </results> </sparql> * http://www.w3.org/TR/rdf-sparql-protocol/
    • Simple Protocol * HTTP Binding Request * SOAP Binding <?xml version="1.0" encoding="UTF-8"?> <soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/ XMLSchema-instance"> <soapenv:Body> <query-request xmlns="http://www.w3.org/2005/09/sparql-protocol-types/#"> <query>SELECT ?z {?x ?y ?z . FILTER regex(?z, 'Harry')}</query> </query-request> </soapenv:Body> </soapenv:Envelope> Response <sparql ...> <head> <variable name="x"/> <variable name="mbox"/> </head> <results> <result> <binding name="x"> <bnode>r2</bnode> </binding> <binding name="mbox"> <uri>mailto:bob@work.example.org</uri> </binding> </result> </results> </sparql> * http://www.w3.org/TR/rdf-sparql-protocol/
    • Here is a Semantic Web?
    • SPARQL 1.1
    • SPARQL 1.1 Aggregate Functions Subqueries Negation Projection Expressions Query Language Syntax Property paths Commonly used SPARQL functions Basic federated query * WG , .
    • Aggregate functions Ex. COUNT, MAX, MIN, SUM, AVG SELECT COUNT(?person) AS ?alices WHERE { ?person :name “Alice” . } Existing implementation. Garlik’s JXT, Dave Beckett’s Redland, ARQ, Open Anzo’s Glitter,Virtuoso, ARC Status. Required
    • Subqueries Ex. SELECT ?person ?name WHERE { :Alice foaf:name ?person . { SELECT ?name WHERE { ?person foaf:name ?name . } LIMIT 1 } } Existing implementation. ARQ,Virtuoso Status. Required
    • Negation (1/2) Ex. ex) Identify the name of people who do not know anyone. SELECT ?name WHERE { ?x foaf:givenName ?name . OPTION { ?x foaf:knows ?who } . FILTER (!BOUND(?who)) } Existing implementation. RDF::QUERY (unsaid keyword), SeRQL (MINUS keyword), ARQ (NOT EXIST keyword), SQL Status. Required
    • Negation (2/2) SeRQL (MINUS) SELECT x FROM {x} foaf:givenName {name} MINUS SELECT x FROM {x} foaf:givenName {name} ; foaf:knows {who} USING NAMESPACE foaf = <http://xmlns.com/foaf/0.1/> UNSAID PREFIX foaf: <http://xmlns.com/foaf/0.1/> SELECT ?x WHERE { ?x foaf:givenName ?name UNSAID { ?x foaf:knows ?who } }
    • Project Expressions Ex. SELECT ?name (?age > 18) AS over 18 WHERE { ?person :name ?name ; :age ?age . } Existing implementation. Garlik’s JXT, Dave Beckett’s Redland, ARQ,Virtuoso, Open Anzo’s Glitter SPARQL Engine, XSPARQL Status. Required
    • Update Ex. INSERT DATA { :book1 dc:title “new book”; dc:creator “someone”. } DELETE { ?book ?p ?v } WHERE { ?book dc:date ?date . FILTER ( ?date < “2001-01-01T00:00:00^^xsd:dateTime ) ?book ?p ?v. } Existing implementation. ARQ,Virtuoso Status. Required Update with HTTP PUT, DELETE Existing implementation. Garlik’s JXT, IBM’s Jazz Foundation
    • Garlik’s JXT Aggregate Functions Dave Beckett’s Redland Subqueries ARQ Open Anzo’s Glitter Negation Virtuoso Projection Expressions ARC SeRQL Service description RDF::Query Update (REST) SQL XSPARQL IBM’s Jazz Foundation Garlik’s JXT Dave ARQ Open Anzo’s Virtuoso ARC SeRQL RDF::Query SQL XSPARQL IBM’s Jazz Beckett’s Glitter Foundation Redland Aggregation COUNT() O O O O O O SUM() O O O O AVG() O O O O MAX() O O O MIN() O O O Subqueries O O Negation O O O O Project expressions O O O O O O Service description O O O UPDATE O O Protocol O O Enhancements for Update * WG , .
    • Links http://groups.google.com/group/semanticwebstudy?hl=ko http://delicious.com/kwangsub.kim/bundle:RDFTutorial2009 SPARQL (IBM DevWorks) : http://www.ibm.com/developerworks/kr/library/tutorial/x-sparql/ SPARQL Working Group : http://www.w3.org/2009/sparql/wiki/Main_Page
    • . .
    • : http://lab.naver.com : http://semantic.lab.naver.com NHN TF
    • - http://groups.google.com/group/semanticwebstudy?hl=ko