NoSQL Zone is brought to you in partnership with:

I am a Webscience PhD student at the university of Koblenz and the Founder of Social news streams are my research interest. René is a DZone MVB and is not an employee of DZone and has posted 36 posts at DZone. You can read more from them at their website. View Full User Profile

Neo4j Graph Database vs MySQL

  • submit to reddit

For my social news stream application I am heavily thinking about the right software to support my backend. After I designed a database model in MySQL I talked back to Jonas and he suggested to search for a better suiting technology. A little bit of research brought me to a Graph database called Neo4j.

After I downloaded the opensource java libs and got it running with eclipse and maven I did some testing with my Metalcon data set. And I have been very satisfied and the whole project looks very promesing to me. I exported 4 relations from my MySQL Database.

  1. UserUserFriend containing all the friendship requests
  2. UserProfileVisit containing the profiles a user visited
  3. UserMessage containing the messages between users
  4. UserComment containing the profile comments between users

These relations obviously form a graph on my data set. Reading the several 100’000 lines of data and put them into the graph data structure and building a search index on the nodes only took several seconds runtime. But I was even more impressed by the speed with which it was possible to traverse the graph!

Receiving the shortest path between two users of length 4 only took me 150 milliseconds. Doing a full bredthfirst search on a different heavily connected graph with 290’000 edges only took 2.7 seconds which means that neo4j is capable of traversing about 100’000 edges per second.

Now I will have to look more carefully to my usecase. Obviously I want to have edges that are labled with timestamps and retrieve them in orderd lists. Adding key value pairs to the edges and including and index is possible which makes me optimisitic that I will be able to solve a lot of my queries of interest in an efficiant manner.

Unfortunately I am batteling around with Google Webtoolkit and Eclipse and Neo4j which I want to combine for the new metlcon version but I even asked the neo4j mailinglist with an very emberassing question and the guys from neotechnology have been very kind and helpful (even thogh I still couldn’t manage to get it running) I will post an article here as soon as I know how to set everything up.

In General I am still a huge fan of relational databases but for a usecase of social networks I see why graph data bases seem to be the more sophisticated technology. I am pretty sure that I could not have perfomed so well using MySQL.

What is your experience with graph data bases and especially neo4j?


Published at DZone with permission of René Pickhardt, author and DZone MVB.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)


Ash Mughal replied on Thu, 2012/01/26 - 2:09am

Hello Pickhardt

Definitely, graph database Neo4j has proved to be a better technology . Relations easily get imported & hundred thousands of data lines are read to build search index in few runtime seconds. It is speedy which made it more appealing!

advanced java

Mark Unknown replied on Mon, 2011/12/26 - 9:45am

Why choose one or the other? You can easily use both with Spring Data.

Mitch Pronschinske replied on Thu, 2011/12/29 - 11:01am

Very true Mark.  Anyone can check out Spring Data here.  And they have a free book extract too.

Aaron Digulla replied on Fri, 2011/12/30 - 4:42am

Instead of GWT, consider ZK. I've used both and I like GWT (except for the long compile times) but ZK is even better because it doesn't try so desperate to isolate you from JavaScript and HTML.

Kookee Gacho replied on Tue, 2012/06/05 - 1:50am

Neo4j was developed by Neo Technology, Inc., based in the San Francisco Bay Area, US and Malmö, Sweden. Neo Technology board of directors consists of Rod Johnson.-Madison Pharmacy Associates

Carla Brian replied on Sun, 2012/07/29 - 5:27am

Good to see this post. This is helpful. At least we know already their differences.  Good to know about this one. - Instant Tax Solutions Ratings

Comment viewing options

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