Hacker News new | ask | show | jobs
by weavie 4166 days ago
I've only had a brief look at Neo4J, but I really like what I see. Graph databases seem to be marketed as an ideal way to represent a social network or similar where you want to represent the connections with other entities.

I see them as much more than this. I love using document databases because I don't have to worry about strict schemas. However, I lose a lot when I have multiple entities that are related in some way. Say I have a list of books and a list of authors. In MongoDB the book object would just have an id of the author and would then need to do a separate query to get the authors details.

Before graph databases, this sort of data would be best represented in a relational database as they have a really efficient way to join related data together.

However, with graph databases I get the best - and even better - of both of these worlds. My book entity contains a pointer to the author(s), so to query the book and their authors is even faster than a relational database.

In addition there is no fixed schema, so I am not tied down to a strict schema, thus allowing me to iterate faster. This could of course also be seen as a disadvantage - however I see no reason why a graph database couldn't build in the facility to have strong validation on the schema for specific entity types..

What is there not to like about Neo4J?

2 comments

> However, with graph databases I get the best - and even better - of both of these worlds. My book entity contains a pointer to the author(s), so to query the book and their authors is even faster than a relational database.

Many folks take this as a given, but the performance difference is often not that large, and may even be in the other direction, if you build the right index (e.g., on the AuthorID in this case). The index is essentially those pointers as well. If the data fits in memory (Neo4j, in the past at least, has pretty much required that), then the B+-tree index lookup is also very very fast. You would be surprised at how fast PostgreSQL can do even seemingly complex graph-natured queries, e.g., finding, for an author, the co-author with which it has written most books.

In my experience with Neo4J a few years ago, i naively used it as my primary DB. The latency (not suprising given its JVM based) was painful and often there are classic relational aspects that we tried to capture in the graph.

This is ENTIRELY MY FAULT - not Neo4j, they never market it as that - just as MongoDb never markets itself as a true replace for relational problems.

But that said there is plenty to not like about Neo4j if you don't use it right - so make sure you use it for what you need and not what you don't need

I was at a Neo4j intro meetup earlier in the week. They do market it as a primary DB. Maybe the capabilities are different now.