400 likes | 621 Views
Paper Presentation. “ Declarative Updates for RDF Graphs: A n Introduction t o the Language RUL ”. Kllapi Herald (M945) Nomikos Vangelis (M917) 01/03/2008. Query Languages for RDF/RDFS. SPARQL ( W3C Recommendation ) ICS-FORTH RQL (RDFSuite, Atlas) SeRQL (Sesame) RDQL others….
E N D
Paper Presentation “Declarative Updates for RDF Graphs: An Introduction to the Language RUL” KllapiHerald (M945) NomikosVangelis (M917) 01/03/2008
Query Languages forRDF/RDFS • SPARQL (W3C Recommendation) • ICS-FORTH RQL (RDFSuite, Atlas) • SeRQL (Sesame) • RDQL • others….
RQL - A Brief Introduction • declarative query language for RDF/RDFS • relies on a typed data model!!! • literal, resource, class, property, meta-class, bag, seq, alt types • for error detection and safety • for performance (e.g better storage) • follows a functional approach • (e.g subclassof(), superclassof(), leafclass, domain(), range()) • separation of three layers: • meta-schema (e.g. meta-classes such as rdfs:Class) • schema • data Why???
University RDF Schema – An Example Person foaf:name Staff Student Literal UnderGraduateStudent AcademicStaff NonAcademicStaff GraduateStudent teaches assistsWith TeachingAssistant takes Module Economics Maths
RQL vs SPARQL - Schema Querying • Example 1:“Which classes can appear as domain and range of the property teaches?” • SPARQL PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> . SELECT ?X, ?Y WHERE { ?X teaches ?Y . ?X rdf:type rdfs:Class . ?Y rdf:type rdfs:Class . } • RQL SELECT $X, $Y FROM {$X}teaches{$Y} $X, $Y are variables bound to schema classes
RQL vs SPARQL - Schema Querying • Example 2:“Find all properties that have range Module.” • SPARQL PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> . SELECT?P WHERE { ?Prdf:type rdf:Property . ?P rdfs:range Module . } • RQL SELECT @P FROM @P{;Module} @P is a variable bound to property
RQL vs SPARQL - Basic Data Queries • Example 3:“Find all GraduateStudents.” • SPARQL PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . SELECT ?X WHERE { ?X rdf:type GraduateStudent . } • RQL a) GraduateStudent b) SELECT X FROM GraduateStudent{X} Equivalent queries
RQL vs SPARQL - Basic Data Queries • Example 4:“Find all modules and their classes that Koubarakis teaches.” • SPARQL PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . SELECT ?X , ?Z WHERE { ?X rdf:type Person . ?X teaches ?Y . ?Y rdf:type ?Z . ?X foaf:name ?N . FILTER(regex(?N, “Koubarakis”) . } • RQL SELECT Y , $Z FROM {X;Person}teaches{Y;$Z} , {X;Person}foaf:name{N} WHERE N = “Koubarakis” USING NAMESPACE foaf = &http://xmlns.com/foaf/0.1/ Y;$Z retrieves the class of resource Y
RQL - More Complex Queries • Example 5:“Find all UnderGraduateStudents and the number of modules they take.” SELECT X, C FROM UnderGraduateStudent{X} WHERE C = COUNT( SELECT Y FROM {X}takes{Y;Module} ) • Example 6:“Find the persons who are NonAcademicStaff but not TeachingAssistants.” ( SELECT X FROM NonAcademicStaff{X} ) minus ( SELECT Y FROM TeachingAssistant{Y} ) • Example 7: “Find the TeachingAssistant resources which have also been classified under UnderGraduateStudent.” SELECTX FROMTeachingAssistant{X} WHEREexists Y inUnderGraduateStudent SUCHTHAT X=Y
RQLvs SPARQL – A Comparison RQL has some very interesting features that are not present at SPARQL yet!!!
Do we need more? • We presented one more query language! • Are we happy only with SELECT and ASK queries? • Is it useful to have a way to update RDF data? • dynamic environments (e.g Grid Metadata)
RUL – A companion for RQL • a declarative update language for RDF • relies on RQL and on its typed data model (ICS-FORTH ) • each RUL operation always result in a consistent state of the updated graph (i.e effects and side-effects of each RUL operation) • does not deal with • schema updates - blank nodes • containers - collections • we will present the semantics of RUL in an informalway by a series of examples.
INSERT for Class Instances • Goal • insert new class instances and classify them • insert new classification links for existing class instances • Syntax INSERT QualClassExp(ResourceExp) [FROM VariableBinding] [WHERE Filtering] [USINGNAMESPACE NamespaceDefs] • Example: “Make the resource with URI http://www.di.uoa.gr/Koubarakis an instance of the class AcademicStaff.” INSERT AcademicStaff(&http://www.di.uoa.gr/Koubarakis)
INSERT for Class Instances A 1. INSERT A(&r4) D B 2. INSERT D(&r1) 3. INSERT A(&r1) C 4. INSERT B(&r1) 5. INSERT C(&r2) &r2 &r3 &r1 &r4 No changes
DELETE for Class Instances • Goal • delete a class instance • delete classification links • Syntax DELETE QualClassExp(ResourceExp) [FROM VariableBinding] [WHERE Filtering] [USING NAMESPACE NamespaceDefs] • Example: “Delete all instances of class Person except for the resources with URIs http://www.di.uoa.gr/Koubarakis and http://www.di.uoa.gr/Zoi.” DELETE $C(X) FROM $C{X} WHERE $C=Person AND ( X != &http://www.di.uoa.gr/Koubarakis AND X != &http://www.di.uoa.gr/Zoi )
&r1 DELETE for Class Instances L A K 1. DELETE B(&r1) B P1 Literal M 2. DELETE B(&r3) 3. DELETE C(&r2) C Literal P2 N 4. DELETE M(&r4) 5. DELETE L(&r5) P1 P2 “str2” &r4 &r2 &r5 “str3” P1 P1 &r3 P1 “str1” “str4”
REPLACE for Class Instances • Goal - replace an existing class instance with a new one • Syntax REPLACE QualClassExp (OldResourceExpNewResourceExp) [FROM VariableBinding] [WHERE Filtering] [USING NAMESPACE NamespaceDefs] • Example:“The information that Manolis is academic staff is incorrect. The correct information is that Koubarakis is academic staff.” REPLACE AcademicStaff(&http://www.di.uoa.gr/Manolis &http://www.di.uoa.gr/Koubarakis )
Replace for Class Instances Literal A 1. REPLACE A(&r1 r1_new) P1 2. REPLACE B(&r2 &r4) B C 3. REPLACE A(&r3 &r3_new) &r3_new &r1 &r1_new &r3 P1 REPLACE is not equivalent to a DELETE followed by an INSERT &r4 &r2 P1 “str1” “str2”
A P1 B Literal REPLACE B(&r1&r2) P1 “str1” &r2 &r1 A P1 B Literal DELETE B(&r1) INSERT B(&r2) P1 “str1” &r2 &r1
REPLACE classification for Class Instances • Goal • modify the classification of a class instance • Syntax REPLACE OldQualClassExp NewQualClassExp (ResourceExp) [FROM VariableBinding] [WHERE Filtering] [USING NAMESPACE NamespaceDefs] • Example:“KT finished! We want to reclassify Zoi as instance of class GraduateStudent.” REPLACE TeachingAssistant GraduateStudent(&http://www.di.uoa.gr/Zoi)
REPLACE classification for Class Instances D Literal P1 A 1. REPLACE A D(&r1) Literal B K 2. REPLACE B K(&r2) P2 3. REPLACE B K(&r3) C No changes! &r3 P1 &r2 &r1 P2 “str2” “str1”
INSERT for Property Instances • Goal • insert new property instances to existing resources • Syntax INSERT QualPropertyExp(SubjectExp, ObjectExp) [FROM VariableBinding] [WHERE Filtering] [USING NAMESPACE NamespaceDefs] • Example:“Make the resource http://www.di.uoa.gr/Koubarakis teach the resource http://www.di.uoa.gr/KT.” INSERT teaches(&http://www.di.uoa.gr/Koubarakis, &http://www.di.uoa.gr/KT)
INSERT for Property Instances P1 A B P2 C 1. INSERT P2(&r3, &r4) 2. INSERT P2(&r2, &r4) 3. INSERT P2(&r1, &r4) &r1 P1 P1 P2 &r4 No changes! &r2 P2 &r3
DELETE for Property Instances • Goal • remove instatiation links • Syntax DELETE QualPropertyExp(SubjectExp, ObjectExp) [FROM VariableBinding] [WHERE Filtering] [USING NAMESPACE NamespaceDefs] • Example:“Delete the resource http://ww.di.uoa.gr/Koubarakis as teacher of KT.” DELETE teaches(&http://www.di.uoa.gr/Koubarakis, &http://ww.di.uoa.gr/KT)
DELETE for property instances P1 A D 1. DELETE P1(&r1, &r3) P2 B C 2. DELETE P2(&r2, &r4) 3. DELETE P1(&r5, &r6) P1 &r3 &r1 P2 P1 &r4 &r2 P2 &r5 &r6
REPLACE for Property Instances • Goal • replace the subject or the object of a property instance • Syntax REPLACE QualPropertyExp (OldSubjectExp[<-NewSubjectExp], OldObjectExp[<-NewObjectExp]) [FROM VariableBinding] [WHERE Filtering] [USING NAMESPACE NamespaceDefs] • Example:“Make Zoi teach KT instead of Koubarakis.” REPLACE teaches(&http://www.di.uoa.gr/Koubarakis&http://www.di.uoa.gr/Zoi, &http://www.di.uoa.gr/KT)
REPLACE for Property Instances P1 A D Literal P2 B Literal 1. REPLACE P2(&r2 &r3, "str1") P3 C Literal 2. REPLACE P2(&r2 &r1, "str1") 3. REPLACE P3(&r4, “str2“ “str3”) &r3 No changes! P3 “str2” P2 &r1 &r2 &r4 P2 “str3” “str1”
REPLACE classication for Property Instances • Goal • modify the classification of one or more property instances • Syntax REPLACE OldQualPropertyExp NewQualPropertyExp(SubjectExp, ObjectExp) [FROM VariableBinding] [WHERE Filtering] [USING NAMESPACE NamespaceDefs] • Example:“Make Koubarakis not teach KT! Koubarakis takes KT! ” REPLACE teaches takes(&http://www.di.uoa.gr/Koubarakis, &http://www.di.uoa.gr/KT)
&r5 &r3 &r2 &r4 REPLACE classication for Property Instances P3 P1 A B Literal P2 P4 1. REPLACE P2 P1(&r1, &r3) C D P5 2. REPLACE P3 P1(&r2, “str1”) 3. REPLACE P1 P2(&r1, &r2) 4. REPLACE P4 P5(&r3, &r4) P3 P1 5. REPLACE P5 P4(&r3, &r5) &r1 “str1” P1 P4 P5 P2 No changes! P5 P4
Update Sequences • The easy way • we can express sequences of updates by writing multiple RUL statements one after the other • The RUL way • sequences of primitive updates inside a single RUL statement • Sequences of Updates – 2 types • of the same kind (e.g. a lot of insertions) • of different kinds (multiple INSERT, DELETE or REPLACE clauses before the FROM clause of an update statement)
Update Sequences Examples • Example:“Insert the resource with URI http://www.di.uoa.gr/KT as instance of the class Module and make resource Koubarakis its teacher.” INSERTModule(&http://www.di.uoa.gr/KT), teaches(&http://www.di.uoa.gr/Koubarakis ,&http://www.di.uoa.gr/KT) • Example: “All TeachingAssistants who assistsWith KT must take the lesson as UnderGraduateStudent.” DELETE assistsWith(X,&http://www.di.uoa.gr/KT ) REPLACE TeachingAssistantUnderGraduateStudent(X) INSERT takes(X, &http://www.di.uoa.gr/KT ) FROM TeachingAssistant{X} WHERE {X} assistWith {&http://www.di.uoa.gr/KT } order of execution does matter
SPARQL/Update (SPARUL) • supported by Hewlett-Packard • it uses a syntax derived from SPARQL • express updates to an RDF store • SPARQL/Update provides the following facilities: • Insert new triples to an RDF graph • Delete triples from an RDF graph • Perform a group of update operations as a single action • Add a new RDF Graph to a Graph Store • Remove an RDF graph from a Graph Store
SPARQL Update - Examples • Example 1: “Make the resource with URI http://www.di.uoa.gr/Koubarakis an instance of the class AcademicStaff.” PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . INSERT { <http://www.di.uoa.gr/Koubarakis> rdf:type AcademicStaff } • Example 2:“Delete all UnderGraduate Students who takes KT.” DELETE FROM <http://www.di.uoa.gr/Students> { ?X rdf:type UnderGraduateStudent} WHERE { ?X takes <http://www.di.uoa.gr/KT> } graph
Remarks It supports Graph Management and inherits all the advantages (and disadvatages) of SPARQL But… It lacks formal/informal semantics!!!
Conclusion • A lot of effort on Query Languages for RDF data retrieval • No W3C Reccomendation for RDF Updates • Each system has its own way So… We are waiting for W3C recommendation!!!
Thank you!!! grad0917@di.uoa.gr grad0945@di.uoa.gr
Links • RQL: http://139.91.183.30:9090/RDF/RQL/ • Sesame RQL: http://www.openrdf.org/doc/rql-tutorial.html • RUL:http://139.91.183.30:3026/RULdemo/demo/ • SPARQL: http://www.w3.org/TR/rdf-sparql-query/ • SPARQL/Update:http://jena.hpl.hp.com/~afs/SPARQL-Update.html