close

  menu      DavidRodenas
CONTACT  

Neo4j

A fashion open-source database designed to store graphs.


Neo4j stores data as a graph instead of tables as most of databases engines does. The key point is that while most of databases are fast listing values but slow making joins, graph databases are fast following joins but not so fast listing values.

Neo4j can work as a library (very fast access for a single app) or as a database server shared with multiple apps.

GraphDatabaseService graphDb;
Node firstNode;
Node secondNode;
Relationship relationship;

graphDb = new GraphDatabaseFactory().newEmbeddedDatabase( DB_PATH );
registerShutdownHook( graphDb );

firstNode = graphDb.createNode();
firstNode.setProperty( "message", "Hello, " );
secondNode = graphDb.createNode();
secondNode.setProperty( "message", "World!" );
 
relationship = firstNode.createRelationshipTo( secondNode, RelTypes.KNOWS );
relationship.setProperty( "message", "brave Neo4j " );

System.out.print( firstNode.getProperty( "message" ) );
System.out.print( relationship.getProperty( "message" ) );
System.out.print( secondNode.getProperty( "message" ) );

firstNode.getSingleRelationship( RelTypes.KNOWS, Direction.OUTGOING ).delete();
firstNode.delete();
secondNode.delete();

graphDb.shutdown();

«  MySQL
OpenMP  »