1

I am trying to decide between a NoSQL (MongoDB) or a SQL (Oracle) database for my project. This database will be used to store output files from a set of parameters.

I can model this as a MongoDB document, so that the parameters and their values are stored as a key:value pair. Afterwards, I would query those documents in Java by sending an example HashMap.

I can also model this as a SQL table. In this situation I would create a hash index based on the parameters and their values. I would query those entries of the table in Java by rebuilding the hash and sending it within a SQL Select.

I figured that the NoSQL modeling makes more sense, since the parameters and their values would be stored on a cleaner manner. Also, querying it would make more sense on a maintenance point of view. Rebuilding a hash and making sure the hash is consistent across the board would be a maintenance overhead with SQL.

On the other hand, I have made some testing with both alternatives and the NoSQL one seems to be the slowest to return the queries (double the time of a SQL query by the has index, and it makes sense to be this way).

This seems to me like a common problem someone had before me. Still, I could not find any comparison of this type of modeling on NoSQL and SQL on an article so that I could read from someone else's perspective.

Is this a common problem on database modeling? Did I go right about testing it? Do my conclusions make sense? Is there anywhere I can find an article with a simillar problem? I have searched a lot for it and all I could find were superficial comparisons between NoSQL and SQL. Maybe I have not used proper keywords for it.

  • I think for your use case as well, the standard comparisons between NoSQL and SQL should suffice to make a decision. What are those output files btw? and What scale are you looking at? SQL doesn't scale across nodes very well. – skott Jan 8 at 18:01
  • Think of those files as a file system absolute path reference. I am matching a combination of parameters and values to a file path reference result. I can query that via NoSQL document keys and values, or build a hash for SQL every time and use that as an index. I have not decided about scaling yet. I am still unsure of whether I will distribute database instances or use just one. – Gabriel Robaina Jan 8 at 18:12
  • If that's the case, SQL or NoSQL would work equally well to start small. Either way once you see that you are scaling up you can move to NoSQL if required and there are tools available to migrate to NoSQL. It then comes down to what response times you require. NoSQL for a simple lookup should not be that slow either, you can check for Mongo indexes as well. – skott Jan 8 at 18:18
  • 1
    I have studied MongoDB indexes as you suggested. It seems to solve the main differente I have described between SQL and NoSQL. Would you mind writing an answer so that I can give you points for it? – Gabriel Robaina Jan 9 at 19:26
  • It really depends on the data model and how effective the hash is. Can you post an example of the data structure? – Martin K Jan 10 at 22:56
1

For simple lookup of hash, SQL and NoSQL work equally well, especially on the single machine.

In case of MongoDB, you can use the MongoDB indexes, similar to MySQL indexes. NoSQL would generally give you good performance for lookups with indexes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.