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

    Path finding in RDF space

    573472
      Hi,

      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?

      Thanks!
        • 1. Re: Path finding in RDF space
          Mannamal-Oracle
          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'.

          Melli

          -- 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
          UNION
          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)
          VALUES( 'NATURE', 'LOGICAL','NATURE_NODE$', 'NATURE_LINK$', 'DIRECTED');
          COMMIT;

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