Playing with Neo4J

Posted May 14, 2008

Almost all of the apps I build rely heavily on graphs — not pretty charts, but rather networks of people, places, things, or concepts that relate to each other in different ways. I've been looking for alternatives to standard table oriented relational databases, and the most interesting project I've found so far is Neo4J.

The concept behind Neo4J is simple, and it's relatively easy to get started with if you're comfortable with Java. The basic semantic concepts you work with are nodes, relationships, and properties. For example, Peat (node) is friends (relationship) with Howard (node). Nodes and relationships both support freeform key:value properties, so I could set a birthday on the Howard node, or a note about how we met on the Friend relationship. Very simple and flexible.

The real power in Neo4J is in it's traversal system — complex graphs are pretty useless without being able to pull information out of them, and SQL based systems pretty much suck at handling complex queries through nested or recursive structures. Neo4J's "traversers" are much simpler to build, and feel pretty darned quick.

What I'm really enjoying is the simplicity of the system. The API only describes 12 classes, and there's only 3 or 4 you need to be familiar with. The jar file weighs in at under half a meg. The "hello world" example is readable straight out of the gate. There's even a command line shell for exploring your data. Simple concepts. Easy to learn. Small foot print.

Pretty cool stuff.

If your work involves designing and building systems that rely heavily on relationships, Neo4J is definitely worth checking out. Caveats? As of May 13th, it's still in beta — but it looks like the 1.0 release is around the corner.

comments powered by Disqus