Thursday, May 29, 2014

Neo4j Tutorial - Creating new Database in Neo4j

Creating new Database in Neo4j

Before Starting neo4j community click the browse option
enter image description here
and choose a different directory
enter image description here
enter image description here
and click start buttton.
enter image description here
New database created on that direcory

Wednesday, April 16, 2014

Neo4j Tutorial - Neo4j Bidirectional Relationship

There is no need to create bidirectional relationship in Neo4j. If you created a relationship between two nodes means that act as forward and reverse direction.

The idea lying on the Symbol   >  . because if you have statement like below

MATCH (n)-[:REL]->(m)

the above query will run in forward direction only . 

MATCH (n)<-[:REL]-(m)

the above query will run in reverse  direction only .  


MATCH (n)-[:REL]-(m)

the above query will run in both forward and reverse  direction

so if you want to move forward and reverse means remove the Symbol(> or <)

Neo4j Tutorial - Cypher Query in Java


This program shows how to use Cypher Queries in java using java api. Its same as like passing SQL queries in JDBC. Here tables are replaced with Nodes and if you returning 2 nodes means the column count is 2. Every node considered as Row.


import java.util.Iterator;
import java.util.Map;
import org.neo4j.cypher.javacompat.ExecutionEngine;
import org.neo4j.cypher.javacompat.ExecutionResult;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.factory.GraphDatabaseFactory;

public class ExecutionEngine1 {
   
     private static final String DB_PATH = "C:/Users/Bharathi/Documents/Neo4j/default.graphdb/";
   


      
       public static void main( final String[] args )
       {
      
         
      
           GraphDatabaseService graphDb = new GraphDatabaseFactory().newEmbeddedDatabase( DB_PATH );

          ExecutionEngine e=new ExecutionEngine(graphDb);
          ExecutionResult rs=e.execute("match n return n limit 25");
          System.out.println(rs.columns().size());
         
         Iterator<Map<String, Object>> i= rs.iterator();
        
         Iterator<Node> n_column = rs.columnAs( "n" );
        
         while(n_column.hasNext())
         {
             System.out.println(n_column.next().getProperty("name"));
         }
          
       }   
      
}

Friday, April 11, 2014

Neo4j Tutorial - Graph Database

Graph Database is a database(DBMS), which used traditional graph methodology to store and display data. Graph database comes under No SQL .
No SQL has many category. They are
1. Document Database
2.Property Database
3.Key value Database
etc
There are many graph databases available in the Industry. Some of them are

Neo4j
HyperGraphDB
OrientDB
Titan

Graph databases use query language to manage data, which is called Cypher Query Language. There is no standard like SQL query  but its easy to learn if you basics of sql.

Monday, April 7, 2014

Neo4j Tutorial - Introduction to Neo4j- Graph Database

Neo4j is one of No SQL database, which comes undes Graph Database category. Here everything is connected in node format. The below Diagram explains how the data is stored in Graph databases like neo4j.
Neo4j uses SQL like query language to retrieve data from database which called as Cypher Query Language