Which Database fits my business best?

S Eswar
5 min readApr 17, 2019

Recently, I was asked an interesting question by one of my colleagues with an entrepreneurial mindset: How do you choose which database is the right for your application?

This kicked off the idea in my head to write this up for such people to refer.

Fundamentals

There are essentially two kinds of databases, broadly divided into SQL and NoSQL type. Some of the popular SQL databases is MySQL, SQLite, PostgreSQL, etc and popular NoSQL databases are Neo4j, MongoDB, Redis, Cassandra, RavenDB, etc. The difference between a SQL and NoSQL type DB is shown below. The essential differences in SQL and NoSQL can be picked up from anywhere but let me put the differences based on various factors considered to choose a DB to use.

Differences

  • Language
  • Data Storage
  • Complex queries
  • Scalability
  • Community Help
  • Structure and Orientation

Language

One of the major differences between an SQL and NoSQL DB is the language. For SQL databases, it’s Structured Query Language that is used for defining and manipulating data. This allows SQL to be extremely versatile and widely-used — however, it also more restrictive in nature. It requires predefined schemas to determine the structure of the data before you even begin to work with it. The data must also follow the same structure as well, which can entail significant upfront preparation along with careful execution.

For a NoSQL DB, because of the dynamic schema for unstructured data and the data can be stored in many different ways, it’s extreme flexibility allows you to create documents without much planning and definition. Fields can be added on the fly, and therefore the syntax varies from database to database. Due to this, it’s like learning many languages. However, it also allows you to give each document its own unique structure, providing you with more freedom overall.

Generally, the different languages for the databases vary majorly in the syntax and can by far be easily picked up within a short span of time.

Example:

SQL: select p.* from prducts as p; CQL: match (p:product) return p;

Data Storage

When it comes to handling hierarchical data NoSQL database proves to be a better fit since it follows the key-value pair way of storing data which is similar to JSON data. In case of handling big data, NoSQL database is the go-to option because of extreme variations and volume. Nevertheless, we can see that JSON data type is also implemented in SQL format but better handled in a NoSQL DB because of it’s the unstructured and key-value type of storage.

Complex Queries

SQL databases stand tall when it comes to handling query intensive complex databases. The queries in themselves are more powerful in SQL in comparison to NoSQL. Because of the structured nature of the database, better performance is archived from the SQL query. On a high level, NoSQL doesn’t have standard interfaces to perform complex queries.

Scalability

This factor entirely ties to the application at hand. SQL databases are scalable vertically whereas NoSQL databases are horizontally scalable. SQL can handle the load on a single server while NoSQL databases can handle increased traffic simply by adding more servers to the database. NoSQL databases have the ability to become larger and much more powerful, making them the preferred choice for large or constantly evolving data sets.

Community Help

SQL seems to have a lot more community, inclined towards it because of its wide utility and popularity. Bug fixes, error fixes, etc. are therefore easily found for the SQL community as compared to a NoSQL database community. The NoSQL community is more like a divided world scattered across the different databases.

Structure and Orientation

Apart from the fact that SQL is a structured database and NoSQL is an unstructured database, we should also consider the orientation. The SQL(Oracle) database is also called a row-oriented database. Data is grouped into rows and columns. There are also column-oriented databases that have certain use cases, advantages, and are different in architecture but not in conception to such a large degree. So, they are not so fundamentally different as SQL versus NoSQL. But this orientation functionality could also affect the best database fit for your business.

The Right Choice?

The question to be addressed here is which database is right for your business or application. There’s no unique answer to it. There may be many good fits for your business. But, to answer the question, we’ve got to first analyze the required or inherent functionalities in the data to be handled. If the data has a pre-defined structure or can be structured and if the futuristic data must be consistent with a structure, then SQL is a good option. However, if there’s no particular structure to the data and can change dynamically with time, NoSQL database is a good option. Today, many business solutions lie in using SQL and NoSQL databases coherently.

Let me take some examples of SQL kind of data:

Example:

{ name: "Akshay",
marks: 80
}

In terms of SQL, the user would first create a schema like the one below before they could add data to the database:

CREATE TABLE studentMarks (
name varchar,
marks int
);
##insert statement in SQL
INSERT INTO studentMarks (student, marks)
VALUES ("MyName", 100);

For a NoSQL database, say MongoDB, you would use the database API to insert data like this:

db.studentClasses.insert( { name: "MyName", marks:100} )

So, the insertion for an SQL and NoSQL is differently implemented but not poles apart. The features available are very similar in both SQL and NoSQL databases.

However, one very important thing to consider: Open source. If with all the analysis, you have nailed it, a NoSQL database for your business, considering the functionalities, etc. Great, however, the story doesn’t end here. Which NoSQL database? So, one other factor for you to nail the right choice could be if the database is open source(if you plan to save some money).

Conclusion

In conclusion, let’s say not only choosing the correct database for your organization is an important decision, its not as simple as black and white. I always have an inclination to support the underdogs(even in technology) and therefore I must say that NoSQL databases are quickly becoming a major part of the database landscape today. They are proving to be a real game-changer in the IT arena having numerous benefits, including lower cost, open-source availability, and easier scalability. This makes NoSQL databases, an appealing option for anyone thinking about integrating into Big Data. However, being some young technology makes them slightly more volatile. On the other hand, SQL databases have proven themselves for over 40 years and use long-established standards that are well defined. They have a huge community of experts behind them, and the opportunity for collaboration is limitless.

Overall, the decision of using SQL versus NoSQL for business is not entirely black and white; it requires some comparing and contrasting to determine which database best fits your specific needs. With the proper amount of research and preparation, however, you will ensure that the database you choose provides an efficient and streamlined management system for your organization.

Please feel free to post any comments and queries regarding the article. I will try and respond to them in my best capabilities.

--

--

S Eswar

I am a Data Scientist by profession and a multipod by nature. We can connect on linkedin.com/in/sathiraju-eswar/