Monday, September 29, 2008

Mavenized Neo4J example

The weekend after JavaZone, I was one of the participants on a "GeekCruise", where we looked into emerging technologies such as Qi4J, Neo4J and Enterpricy stuff.
Matrix diagram
In short, Neo4J is a network/graph database that promises to deliver Web 3.0, Semantic Web and RDF greatness. Its advantages are fast specific types of search, graph traversal and shortest route. It can also store partially structured information, eg. V1.0 and v1.1 of Person in the DB at the same time. It also integrates well with Qi4J, you don't need ORMaping, and the graph can be read from and persisted to RDF.

//Setting up the database in a folder called myNeoDB
NeoService neoDb = new EmbeddedNeo("myNeoDB");
//Create test dataset
Node neo = neoDb.createNode();
neo.setProperty("name", "Thomas Andersson");
Node trinity = neoDb.createNode();
neo.createRelationshipTo(trinity, MyRelationShipTypes.KNOWS);

Queries can be done with SPARQL, or a traverser:

Traverser friendFinder(Node person) {
return person.traverse(

The Matrix demo is as simple as Unzip og "mvn test"!

No comments:

Post a Comment

Spam will be pruned