Neo4j instead of relational database

I am introducing a web portal based on sinatra / rails, which, possibly, may eventually contain several: many links between tables / models. This is a one-person team and part-time, but a real-world application.

I discussed my nature with someone and was advised to try neo4j. Based on the real “non-sexual” corporate world, I tend to use relational db until it stops scaling or becomes a nightmare due to shards, etc., and then think about something else.

BUT,

  • I am using postgres for the first time in this project along with datamapper and its time to start is very fast.
  • I just understand a few things and build more use cases, so I have to update my scheme (the idea of ​​prototyping and feedback from the beta version). I will not do this in neo4j (other than modifying my requests).
  • It seems very easy to customize your search with neo4j. But Postgres can also do a full text search.
  • Postgres recently announced support for json and javascript. It's amazing if I should just stick to PG and invest more time learning PG (which has a good community) instead of neo4j.

We are looking for us where neo4j is better, especially in the preparation / initial stage of the project. I understand that if a site grows, I may end up with several constant technologies like s3, relational (PG), mongo, etc.

It would also be nice to know how this happens with the Rails / Ruby ecosystem.


Update1:

I got a lot of good answers, and it seems to me that the right thing is to stick with Postgres at the moment (especially since I use the hero)

However, the idea of ​​being incapable of circuits is tempting. Basically, I am thinking about an approach where you do not define a datamodel until you tell 100-150 users, and you yourself figured out a good scheme (business case) for your product, while you just demonstrate the concept and get feedback from limited registrations. Then you can solve the scheme and start with relational.

It would be nice to know if there is an easy-to-use scheme parameter / less persistence (based on the ease of use / configuration for a new user), which may refuse scanning scaling, etc.

+7
source share
3 answers

Graphic databases should be considered if you have a really chaotic data model. They are necessary to express very complex relationships between entities. To do this, they maintain relationships at the data level, while RDBMSs use a declarative approach. Saving relationships makes sense only if the relationships are very different, otherwise you will simply duplicate the data over and over, taking up a lot of space for nothing. To require such a variety of relationships, you have to process a huge amount of data. This is where the graphic databases shine because instant does tons of joins, they just select the record and follow its relationship. To support my expression: you'll notice that every use case on the Neo4j website deals with very complex data.

In short, if you don't feel worried about what I said above, I think you should use a different technology. If it comes to scaling, schematizing, or quickly starting a project, check out other NoSQL solutions (more specifically, column or document based databases). Otherwise, you should stick with PostgreSQL. You could also, as you said, consider preserving the polyglot ,

In your update, you can consider hStore . I think it suits your requirements. This is a PostgreSQL module that also runs on Heroku.

+7
source

I don’t think I agree that you should only use the graph database when your data model is very complex. I am sure that they could work with a simple data model and relationships.

If you have no previous experience with Neo4j or Postgres, then most likely both of them will take quite a long time to study well.

Some things to keep in mind when choosing:

  • It is not only the development of database technology. You should also consider deploying. How easy is it to deploy and scale Postgres / Neo4j?

  • Consider the community and tools around each technology. Is there a data file for Neo4j, for example, for Postgres?

  • Note that data models are significantly different from each other. If you can already think relationally, then I probably stick with Postgres. If you travel with Neo4j, you will make many mistakes for several months with your data models.

  • Over time, I learned to keep it simple when I can. Postgres can be a boring choice compared to Neo4j, but it's boring not to keep you up at night. =)

Also, I have never seen anyone mention this, but you should look at Riak ( http://basho.com/riak/ ). This is a document database that also provides relationships (links) between objects. Not as mature as a graph database, but it can quickly connect multiple objects.

+5
source

The most suitable choice depends on what problem you are trying to solve.

If you have only a few tables, from many to many, a relational database can be great. In general, there is better OR-mapper support for relational databases, since they are much older and have a standardized interface and column column structure. They have also been improved over time, so they are stable and optimized for what they do.

A basic diagram is better if, for example, your problem is more likely with connections between entities, especially if you need connections with a higher distance, for example, "detecting loops (of indefinite length)", some "what friend-friends like". Such things become cumbersome when they are limited to SQL joins. A problem-specific language like cypher in the case of Neo4j makes this much more concise. On the other hand, there are maps between dbs and objects, but not for all frameworks and languages ​​under the sun.

I recently implemented a prototype system using neo4j, and it was very useful to be able to talk about the structure and relationships of our data and to be able to model them one-on-one in the data warehouse. In addition, adding other connections between data points was simple, neo4j a repository without schemas. We ended up switching to mongodb due to performance recording issues, but I don't think we could complete the prototype with this at the same time.

Other NoSQL data stores, such as document, columns, key values, also cover certain functions. Polyglot's insistence is certainly something to look out for, so keep your choice based on a backend reasonably separate from your business logic so you can change your technology later if you learn something new.

+5
source

All Articles