288

With all the hype, it seems really hard to find reliable information on when to use this. So I pose the following questions, and I'm sorry if these are really dumb questions in advance:

  1. Should I use NoSQL for user data? E.g. profiles, usernames + passwords, etc.
  2. Should I use NoSQL for important content? E.g. articles, blog posts, product inventory, etc.

I'm assuming no? And I feel like NoSQL is just for quickly accessible things from which it's OK to lose data. But I also read that NoSQL apps have built-in redundancy so that I don't lose data?

Also, if the above 2 examples are bad, could you give me specific business use cases where I would use NoSQL? I see a lot of general descriptions but not a lot of real-world examples. The only things I can think of are user-to-user messaging and analytics.

0

2 Answers 2

204

It really is an "it depends" kinda question. Some general points:

  • NoSQL is typically good for unstructured/"schemaless" data - usually, you don't need to explicitly define your schema up front and can just include new fields without any ceremony
  • NoSQL typically favours a denormalised schema due to no support for JOINs per the RDBMS world. So you would usually have a flattened, denormalized representation of your data.
  • Using NoSQL doesn't mean you could lose data. Different DBs have different strategies. e.g. MongoDB - you can essentially choose what level to trade off performance vs potential for data loss - best performance = greater scope for data loss.
  • It's often very easy to scale out NoSQL solutions. Adding more nodes to replicate data to is one way to a) offer more scalability and b) offer more protection against data loss if one node goes down. But again, depends on the NoSQL DB/configuration. NoSQL does not necessarily mean "data loss" like you infer.
  • IMHO, complex/dynamic queries/reporting are best served from an RDBMS. Often the query functionality for a NoSQL DB is limited.
  • It doesn't have to be a 1 or the other choice. My experience has been using RDBMS in conjunction with NoSQL for certain use cases.
  • NoSQL DBs often lack the ability to perform atomic operations across multiple "tables".

You really need to look at and understand what the various types of NoSQL stores are, and how they go about providing scalability/data security etc. It's difficult to give an across-the-board answer as they really are all different and tackle things differently.

For MongoDb as an example, check out their Use Cases to see what they suggest as being "well suited" and "less well suited" uses of MongoDb.

5
  • 19
    The claim about NoSQL not supporting joins is misleading. Some NoSQL databases are actually far better at joins than relational databases. Some don't support them at all. This answer seems to be more about MongoDB in particular than about NoSQL in general.
    – Alan Plum
    Feb 25, 2015 at 10:26
  • 1
    Great summary. @AlanPlum, what specific NoSQL databases are you referring to?
    – brian
    May 18, 2016 at 1:11
  • 2
    @brian I'm a contributor to ArangoDB (arangodb.com), which is a mix of a document database (think MongoDB) and a graph database (think Neo4J) with not only cheap joins but also real transactions. That said, NoSQL databases are not a homogeneous group and it's impossible to generalize from any one NoSQL database to the entire "category".
    – Alan Plum
    May 24, 2016 at 11:38
  • 1
    If you find yourself considering using RDBs because "joins aren't supported" in NoSQL, I highly suggest watching this video from AWS re:Invent. Breaks down the whole NoSQL approach! Helped me a lot. youtu.be/HaEPXoXVf2k Oct 14, 2019 at 15:52
  • 1
    If you store the data properly in nosql, in most cases, you won't need more than one db table, hence, no need for joins.
    – Ash Singh
    Oct 13, 2021 at 4:38
10

I think Nosql is "more suitable" in these scenarios at least (more supplementary is welcome)

  1. Easy to scale horizontally by just adding more nodes.

  2. Query on large data set

    Imagine tons of tweets posted on twitter every day. In RDMS, there could be tables with millions (or billions?) of rows, and you don't want to do query on those tables directly, not even mentioning, most of time, table joins are also needed for complex queries.

  3. Disk I/O bottleneck

    If a website needs to send results to different users based on users' real-time info, we are probably talking about tens or hundreds of thousands of SQL read/write requests per second. Then disk i/o will be a serious bottleneck.

5
  • 28
    I don't understand what could be problem with RDBMS for #2. And NoSQL have less disk I/O as per #3?
    – avi
    Jun 30, 2014 at 6:46
  • 6
    As @avi says, I think there's no problem for #2 as long as you query the tables over the index. Millions of rows? Ok, retrieve only the indexes I wanna use
    – Aritz
    Mar 31, 2015 at 8:41
  • 13
    #2 and 3 are both false. For 2, I've done performance tests on importing/exporting data and seen SQL Server 2014 crush Mongo on large data imports and exports. For 3, strongly typed data in SQL typically takes (I've seen over 50% before compression) up much less space than document databases.
    – brian
    May 18, 2016 at 1:04
  • 8
    Yeah, and even for #1, I just don´t get it. Scaling up is part of the clustering contract all major rdbms propose
    – Sebas
    Feb 8, 2017 at 12:03
  • 3
    All three of these are wrong if you have unlimited money
    – Chazt3n
    Jul 10, 2019 at 22:54

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