Presentation is loading. Please wait.

Presentation is loading. Please wait.

Ontology Views Update Marianne Shaw Nov. 26, 2007.

Similar presentations


Presentation on theme: "Ontology Views Update Marianne Shaw Nov. 26, 2007."— Presentation transcript:

1 Ontology Views Update Marianne Shaw Nov. 26, 2007

2 Use Case Queries Most gathered from Onard’s RADLEX notes –Transitive closure –Getting a subtree from a graph –Deleting an entity (leaf node, non-leaf node, subtree) from a graph –Adding an entity (leaf node, non-leaf node, subtree) into a graph –Changing an attribute of an entry –Taking a subset of a graph by only taking a few relations –Copy a graph Defined in Datalog Converted to SPARQL-like syntax

3 Gather subtree from a graph G(x,y) Define in Datalog S(root, x) :- G(root,x), root='liver' S(x,y) :- S(_,x),G(x,y) Convert to a SPARQL-like language –How do we represent recursive queries? –How do we represent subqueries? –How do we copy nodes/edges in graph?

4 Recursion Why? –RDF is a graph; we need to be able to trace arbitrary paths and construct/glean subgraphs –SPARQL does not currently support it How do we get it? –PostgreSQL, MySQL – no support –MS SQL Server, IBM db2 – limited support

5 SQL Server / IBM db2 Recursion Common Table Expressions (CTE) WITH tc (subj, prop, obj, lvl) AS ( SELECT subj, prop, obj, 0 from graph UNION ALL SELECT g.subj, g.prop, t.obj, lvl+1 FROM graph g, tc t WHERE (g.obj = t.subj) AND (g.prop = t.prop) AND (lvl < 30) ) SELECT subj, prop, obj, lvl FROM tc

6 SQL Server / db2 Limitations Only allows linear recursion –FMA hierarchy depth: part(~20), branch_of(>20) Does not handle data with loops –Performs bag instead of set union between iterations –Cannot use DISTINCT to prevent dups –Must artificially limit number of iterations using “lvl” SLOW –10 iterations for transitive closure on FMA stopped after 4 days; 5 iterations take ~40mins –For comparison, stored procedure in PostgreSQL took 8 hours

7 Recursion: alternatives? Other types of dbs –BRAHMS – out of SPARQLer group –DBs for XPath ? Perform recursion in Java instead of db ? Are path expressions sufficient, or do we need general recursion?

8 Gather subtree from a graph G(x,y) SPARQL+SQL like language? WITH GRAPH subgraph AS ( CONSTRUCT { dl:Liver ?a ?b } WHERE { dl:Liver ?a ?b } UNION// SET union CONSTRUCT { ?c ?d ?e } FROM NAMED subgraph WHERE { GRAPH subgraph { ?a ?b ?c } ?c ?d ?e } ) CONSTRUCT { ?a ?b ?c } FROM subgraph

9 SubQueries [Schenk] CONSTRUCT { ?subj ?prop ?obj } FROM FROM <CONSTRUCT { ?s ?p ?o } FROM WHERE { ?s ?p ?o. FILTER REGEX(?p, 'hasVolume', 'i') }> WHERE { ?subj ?prop ?obj. FILTER REGEX(?prop, 'volume', 'i') }

10 SubQueries and Recursion Use named subqueries for recursion CONSTRUCT { ?subj ?prop ?obj } FROM NAMED subgraph < CONSTRUCT { dl:Liver ?a ?b } FROM WHERE { dl:Liver ?a ?b } UNION// set union CONSTRUCT { ?c ?d ?e } FROM NAMED subgraph WHERE { GRAPH subgraph { ?a ?b ?c }. ?c ?d ?e }> WHERE { GRAPH subgraph { ?subj ?prop ?obj }}

11 Copying elements in a graph CONSTRUCT { MyNode(?a) ?b MyNode(?c) } FROM WHERE { ?a ?b ?c } Skolem functions: MyNode() –A unique node is created for each combination of constructor+parameters MyNode(“bob”) always maps to the same node YourNode(“bob”) never maps to MyNode(“bob”) –Copy the node, not just refer to the node from the original graph

12 Skolem functions Need new namespace to ensure unique mappings 0MyNode(“fma:knee”) 1YourNode(“fma:knee”) 2MyNode(“fma:heart”, “fma:knee”) Add provenance info to each new node/edge –MyNode(“fma:knee”)origin “fma:knee” –MyNode(“fma:knee”)originDate11/26/07 Problems: how does this work with non-materialized views?

13 References [Schenk] Schenk, Simon. A SPARQL Semantics Based on Datalog. In KI2007, Osnabrek, Germany. 2007.


Download ppt "Ontology Views Update Marianne Shaw Nov. 26, 2007."

Similar presentations


Ads by Google