SQL Server vs PostgreSQL vs NoSQL Database

Photo by Burst on Unsplash

SQL Server vs PostgreSQL vs NoSQL Database

What is SQL, PostgreSQL, NoSQL and what is the difference?

This article covers the concepts, features and differences between the databases, namely SQL Server, PostgreSQL and NoSQL databases.

Prerequisites

  • Some knowledge about SQL Server and NoSQL

What is a database?

A database is an organized collection of information. But, the way the information is structured and stored is different under various kinds of databases.

There are 8 different kinds of databases, of which we'll discuss 3 in this article.

RDBMS and ORDBMS

A relational database management system(RDBMS) like SQL Server is well-suited for handling traditional application tasks for data processing and administration while an object-relational database management system(ORDBMS) like PostgreSQL is typically used for applications that contain complex objects.

For instance, an ORDBMS can handle new data types like video, audio, and image files that RDBMSs are not equipped to handle.

PostgreSQL

PostgreSQL is an advanced open-source database that supports both JSON (non-relational) and SQL (relational) querying.

History

  • Michael Stonebraker and his associates developed Postgres in 1986.

  • In 1990, support for PL/ pgSQL and ACID compliance was added to PostgreSQL.

PostgreSQL supports Python, PHP, Perl, Tcl, Net, C, C++, Delphi, Java, JavaScript (Node.js), and more.

SQL Server

SQL is a programming language used to manage and query data in an RDBMS. SQL Server is built on top of SQL and was developed by Microsoft as an RDBMS.

History

  • The evolution of SQL Server began in 1988 when Microsoft collaborated with Sybase and Ashton-Tate to help build a database maintenance and creation software that would provide an impetus to Microsoft’s business database market.

  • SQL Server 1.0 was rolled out in 1989.

Since it was developed by Microsoft, it can be easily integrated with its parent company's services like Microsoft Analytics.

SQL Server offers support for Java, JavaScript (Node.js), C#, C++, PHP, Python, and Ruby.

NoSQL Database

NoSQL stands for 'not only SQL'. NoSQL databases are non-tabular databases that store data very differently from relational databases.

History

  • The acronym NoSQL was first used in 1998 by Carlo Strozzi while naming his lightweight, open-source “relational” database that did not use SQL.

  • NoSQL databases were developed for faster processing of data.

A NoSQL database has a dynamic schema which means the data stored can be document-oriented, column-oriented, graph-based, or organized as a key-value store. An example of a NoSQL database is MongoDB.

MongoDB supports ACID transactions like relational databases, but not all NoSQL databases support the same. An important part of non-relational databases is the CAP theorem(Brewer's theorem) which states that a distributed data store cannot simultaneously offer more than 'two of three' established guarantees. The guarantees are:

  • Consistency: The data within the database remains consistent, even after an operation has been executed. For instance, after updating a system, all clients will see the same data.

  • Availability: The system is constantly on (always available), with no downtime.

  • Partition Tolerance: Even if communication among the servers is no longer reliable, the system will continue to function. This is because the servers can be partitioned off, into multiple groups which can’t communicate with each other

Also, NoSQL databases are horizontally scalable. They can handle more traffic by adding more servers to the database.

Comparison

PostgreSQLSQL ServerNoSQL Database
Provides additional support like user-defined datatypes, JSON support etc.Supports data and string processing, procedural programming, and local variablesData stored can be document-oriented, graph-based or as key-value pairs
Offers more complex data types and object inheritanceRestrictive schemaFlexible with the data size
Can employ unlimited CPU coresIts free version can employ up to 24 CPU cores. Its enterprise version can make use of unlimited CPU coresCan employ unlimited CPU cores
In most cases, it's vertically scalableSimilar to PostgreSQLHorizontally scalable
ACID compliantACID compliantThese databases mainly follow the CAP theorem but a few NoSQL databases are also ACID compliant

Conclusion

All of the mentioned types of databases have some pros and cons. The kind of database to go with totally depends on the requirements of the project.