NoSQL Zone is brought to you in partnership with:

Mitch Pronschinske is the Lead Research Analyst at DZone. Researching and compiling content for DZone's research guides is his primary job. He likes to make his own ringtones, watches cartoons/anime, enjoys card and board games, and plays the accordion. Mitch is a DZone Zone Leader and has posted 2576 posts at DZone. You can read more from them at their website. View Full User Profile

Java Object Mapping on Neo4j

02.05.2010
| 16449 views |
  • submit to reddit
Graph databases provide elegant and effective solutions for social networking applications.  NoSQL graph databases like neo4j can solve problems with relational data and social applications.  Taylor Cowan, a software architect who works with the semantic web, recently created jo4neo, which simplifies java object mapping onto neo4j.  DZone spoke with Cowan about graph databases and how jo4neo got started.

NoSQL converts are fanatical about their methods Cowan said.  "I was speaking at the Ordev conference and I saw a guy walk by with a shirt that said 'Ask me about my kick-ass graph database.'"  That's how Cowan was introduced to the neo4j graph database by Emil Eifrem, the CEO of Neo Technology.  In structure, it is very similar to a triple store, which receives data in very simple structures called "triples".  A triple consists of a subject, a predicate (verb), and an object.  

Neo4j is an embedded, disk-based, fully transactional Java persistence engine that stores data structured in graphs (mathematical lingo for networks) rather than in tables.  These graphs consist of nodes and directional edges.   Graph databases can allow more flexible, rapid styles of development with their cyclical or acyclical data structures.  The databases are fairly scalable and they support transactions.  These two ingredients are essential to web-scale applications.  

"These graphs are very elegant at solving problems in the space of social networking," said Cowan.  For example, a piece of software that shows people what their friends bought on a website will perform transitive closures with ease, either by walking the edges of the graph or letting the inference engine take care of it.  Cowan says, "The types of queries become very simple and obvious to the developer."  With graphs, there are no rigid schema and developers can make use of interesting algorithms like shortest paths, maximum flow, and minimum spanning tree.

Database Graph


Cowan soon became interested in making his own contribution to the NoSQL, graph database movement.  "I got kind of excited that there was a lot of movement and interest in non-relational storage systems, and I'm kind of a graphy guy - I like graphs - and even though this isn't semantic web, it has a strong relationship to my previous research," said Cowan.  "I realized I could take the R&D effort I had put into Jenabean and repurpose pieces of it back into being an object-to-graph mapper for neo4j.  I called this project 'Java objects for Neo' (jo4neo)."  Jo4neo is annotations based and there's no XML binding required.  It's based on plain old Java reflection, so it doesn't require byte code interweaving.  Cowan said, "It just takes clean Java classes that have been annotated, and follows those annotations as directions for how your objects can be persisted into the graph store."

Right now jo4neo is a young project - it's first release was in December.  Cowan says he's been blogging about how to do different data patterns and is getting a lot of interest on Twitter and some news groups.  One pattern, shown below, is the user-role pattern:



Cowan says, "Regardless of how comfortable we all are with storing data as a graph, at some point we're going to have to show that information to a consumer on a website or an application."  Technologies like jo4neo will make it easy to bind objects to your view in the development of create-read-update applications.  Cowan says, "If we can get neo4j data into an object, then we're good to go."  He said that jo4neo bridges that gap between objects and the data store.

Comments

Adam Rabung replied on Fri, 2010/02/05 - 8:40am

I've been using neo4j for about 1 year. It absolutely gets out of your way and gives you a dead-simple API for storing and querying your graphs. The maintainers are very responsive on the mailing list. Highly recommended.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.