1 Reply Latest reply on Jan 28, 2015 9:23 PM by alwu-Oracle

    How to permanently store RDF data in Oracle NoSQL database

    Bilal

      Hi,

       

      I'm new to Oracle RDF NoSQL database. I want to use it for storing large amounts of materials data.

       

      My question is how can I permanently save data in Oracle NoSQL database. I mean the way Oracle relational database offers commit to save data and if we turn off the system we can start it exactly from the state where we left. Is it possible in NoSQL database also or we need to upload the triples every time we start it.

       

      Any help will be highly appreciated.

       

      Thanks

        • 1. Re: How to permanently store RDF data in Oracle NoSQL database
          alwu-Oracle

          Hi Bilal,

           

          Yes. One can persist triples in Oracle NoSQL Database. There is no need to upload triples every time your program restarts.

          To get started, you can download and install Oracle NoSQL Database following instructions on the following page.

          Oracle NoSQL Database Downloads

           

          You will also need the following piece.

           

          http://download.oracle.com/otn/nosql-database/rdf_graph_for_nosql_database.zip

           

          To give you an idea about how things work. Here is an example Java code snippet (that is embedded in the above zip).

           

          public class Example1 {

           

            public static void main(String[] args) throws Exception

            {   

              String szStoreName  = args[0];

              String szHostName   = args[1];

              String szHostPort   = args[2];

           

              OracleNoSqlConnection conn = OracleNoSqlConnection.createInstance(szStoreName,

                                                                                szHostName,

                                                                                szHostPort);

             

              // This object will handle operations over the default graph

              OracleGraphNoSql graph = new OracleGraphNoSql(conn);

              graph.clearRepository(); // Clear the graph including inferred triples

             

              graph.add(Triple.create(Node.createURI("u:John"),

                                      Node.createURI("u:parentOf"),

                                      Node.createURI("u:Mary")));

                 

              graph.add(Triple.create(Node.createURI("u:Mary"),

                                      Node.createURI("u:parentOf"),

                                      Node.createURI("u:Jack")));

                

              String queryString = " select ?x ?y WHERE {?x <u:parentOf> ?y}";

             

              System.out.println("Execute query " + queryString);

           

              Model model = new OracleModelNoSql(graph);

              Query query = QueryFactory.create(queryString) ;

              QueryExecution qexec = QueryExecutionFactory.create(query, model) ;

             

              try {

                ResultSet results = qexec.execSelect();

                ResultSetFormatter.out(System.out, results, query);

              }

             

              finally {

                qexec.close();

              }

           

              graph.delete(Triple.create(Node.createURI("u:John"),

                                         Node.createURI("u:parentOf"),

                                         Node.createURI("u:Mary")));

           

              queryString = "select ?x ?y ?z WHERE {?x ?y ?z}";

             

              System.out.println("Execute query " + queryString);

           

              query = QueryFactory.create(queryString) ;

              qexec = QueryExecutionFactory.create(query, model);

             

              try {

                ResultSet results = qexec.execSelect();

                ResultSetFormatter.out(System.out, results, query);

              }

             

              finally {

                qexec.close();

              }

             

              model.close();

              conn.dispose();   

            }

          }

           

          Hope it helps,


          Zhe Wu