1 Reply Latest reply on Apr 23, 2007 7:15 PM by Mannamal-Oracle

    Path finding in RDF space


      My understanding is an advantage of Oracle Spatial system is graph traversal functions. If I have an RDF graph, are there code examples (Java API?) for how to exploit these functions? Specifically, if I'd like to know the shortest path or all paths through the graph that connects two nodes, what would the query look like?

        • 1. Re: Path finding in RDF space
          Yes, the Network Data Model (NDM) functionality of Oracle Spatial supports graph traversal functions. To use that functionality, the RDF graph has to be viewed as an NDM graph, and the following SQL can be used to do so. Essentially the NODE$ and LINK$ views are created, which are the entities that form an NDM graph. Once you have these views, the NDM Java API can be used to traverse the graph. More details on the NDM Java API can be found in the NDM documentation (Oracle® Spatial Topology and Network Data Models
          10g Release 2 (10.2))

          In the sample SQL below, the RDF model name is 'Nature'.


          -- Example SQL for Creating NODE$ and LINK$ views, inserting metadata, and validating network --

          CREATE VIEW nature_node$ AS
          SELECT DISTINCT(a.start_node_id) node_id, b.value_name.getURL() node_name, a.active
          FROM mdsys.rdfm_nature a, mdsys.rdf_value$ b
          WHERE a.start_node_id=b.value_id
          SELECT DISTINCT(c.canon_end_node_id) node_id, d.value_name.getURL() node_name, c.active
          FROM mdsys.rdfm_nature c, mdsys.rdf_value$ d
          WHERE c.canon_end_node_id=d.value_id ;

          CREATE VIEW nature_link$ AS
          SELECT a.link_id, b.value_name.getURL() link_name, a.start_node_id, a.canon_end_node_id end_node_id, a.active
          FROM mdsys.rdfm_nature a, mdsys.rdf_value$ b
          WHERE a.p_value_id=b.value_id ;

          INSERT INTO user_sdo_network_metadata(network, network_category, node_table_name, link_table_name, link_direction)

          SELECT sdo_net.validate_network('NATURE') FROM DUAL;