← All blogs
September 11, 2023·SQLNoSQLDatabasesElectron

NoSQL vs SQL database for Electron Apps

Should you pick a SQL or a NoSQL database for your Electron app? We make a comparison of the main pros and cons for deciding when it’s best which.

Ramón Echeverría
Ramón Echeverría
In the early 1970s, a new approach to data management emerged from IBM Research in the form of relational databases. This was a breakthrough in organizing data and allowed for a more structured way to query, manipulate, and store information. SQL (Structured Query Language) was invented in 1974 as the cornerstone for these databases, and companies like Oracle and Microsoft subsequently brought their SQL databases to life.
Fast forward a few decades, and the internet revolution created unprecedented scalability challenges. This led to the emergence of non-relational databases like MapReduce, Dynamo, Hadoop, and MongoDB, which were designed to manage large data sets distributed across multiple nodes. Since then, there’s been an ongoing debate: SQL or NoSQL? Which is better? When should you use one over the other?
If we look at 2023 Stack Overflow’s developer survey on database technologies, MongoDB and Redis are both very popular NoSQL databases.
Stack Overflow’s developer survey on database technologies
Stack Overflow’s developer survey on database technologies
But should they be that popular? why do developers like them so much?

You should almost always use SQL

I think you should have a strong argument for choosing a NoSQL database, otherwise just use SQL. But what is an example of a strong argument for choosing NoSQL? first, let’s see examples of what is not an argument in favor of NoSQL:
Agility: A common argument in favor of NoSQL is that it provides more agility. The idea is that with NoSQL, you can change your code without altering your underlying data structure. What actually happens is that you end up with an incomprehensible mess of data that becomes a nightmare to manipulate and migrate later when you discover that your data model is flawed.
It is true that in the very early stages you can probably get away without migrations if you choose NoSQL, but i think it’s not worth it. As soon as you have a couple users, you should properly migrate old data when the schema changes, and that’s when NoSQL starts to be a nigthmare.
Also, with current state of LLMs, you can write these migration scripts in minutes. I think it’s definitely not worth it to choose the most important technology in your application based on whether you can save a couple minutes every time you need to change your data model.
Scalability: Another argument is that NoSQL databases scale better. However, databases like Postgres and MySQL can handle millions of queries per second just fine. Companies like Notion and Github use these SQL databases and let's face it, the chances of your application having to scale to a larger extent than theirs are slim to none.

Why is SQL almost always a better choice?

  • Relational Integrity: Data is fundamentally relational, and SQL databases are purpose-built for this.
  • Document Storage: You can store documents in JSONB columns if needed.
  • Schema Rigidity: A rigid schema might sound like a limitation, but it actually makes your data more predictable and easier to work with. Schema migrations in modern libraries can be done in minutes.
  • SQL Language: SQL is widely known. Even non-technical people can quickly learn how to query data, making it a fantastic tool for business intelligence.

When does NoSQL really make sense?

With all these points in favor of SQL, it might seem that NoSQL databases don’t have a place in the ecosystem. But that’s not entirely true.
Performance Metrics: Both Postgres and MySQL can reach 1 million queries per second with powerful hardware. And let's be honest, hardware is cheap these days.
Caching: Redis, a NoSQL database, is often a good use case for caching.
Special Scenarios: In some unique situations, NoSQL databases like MongoDB might be faster or a better fit for the data model. For example, if you have an application that needs to store data without well-defined relationships or with heavy read-write operations that are distributed, NoSQL could be a good choice.
However, the bottom line is that you should have a compelling reason to use NoSQL. If your data model is not fitting well within a relational database schema (which is rare) or if you have extraordinarily large amounts of data where ACID properties are more of a hindrance than a help, then NoSQL may be suitable for you.

The takeaway

If you're not sure whether your electron app, or any kind of app, needs a NoSQL database, you probably don’t. Most developers and businesses choose NoSQL databases without a solid justification, only to regret it later. SQL databases have evolved over decades to provide robust, scalable solutions for a vast array of problems. So, before jumping on the NoSQL bandwagon, take a moment to really assess your needs. Chances are, SQL can handle them just fine. And if you really need a NoSQL database, make sure to check our review of the best NoSQL alternatives for Electron apps.

Get the latest posts, right in your inbox

We write about building products using analytics. No spam, ever.


Understand how well your product is doing today
with Astrolytics

Integrate in minutes and get started with our 30-day free trial.