|Storage||Relational databases are structured.|
Relational databases store data in rows and columns. Each row contains all the information about one entity and each column contains all the separate data points.
|Non-relational databases are unstructured.|
NoSQL databases have different data, storage models.
The main ones are key-value, document, graph, and columnar. We will discuss the differences between these databases below.
* Columns must be decided and chosen before data entry
* Each row must have data for each column.
The schema can be altered later, but it involves modifying the whole database and going offline.
Columns can be added on the fly and each ‘row’ (or equivalent) doesn’t have to contain data for each ‘column.’
|Scalability||Generally not distributed|
SQL databases are generally vertically scalable.
It is possible to scale a relational database across multiple servers, but this is a challenging and time-consuming process.
NoSQL databases are horizontally scalable. A lot of NoSQL technologies also distribute data across servers automatically.
|Examples||Some of the most popular relational databases are MySQL, Oracle, MS SQL Server, SQLite, Postgres, and MariaDB.||Following are the most common types of NoSQL:|
Key-Value Stores: Data is stored in an key-value pairs. Example: Redis, Memcache, and Dynamo DB.
Document Databases: Data is stored in documents (instead of rows and columns in a table) These documents are grouped together in collections. Each document can have an entirely different structure. Example: CouchDB and MongoDB.Wide-Column Databases: Columnar databases are best suited for analyzing large datasets.Example: Cassandra and HBase.Graph Databases: These databases are used to store data whose relations are best represented in a graph. Data is saved in graph structures with nodes, properties (information about the entities), and lines (connections between the entities). Example: Neo4J and InfiniteGraph.
|Querying||SQL databases use SQL (structured query language) for defining and manipulating the data, which is very powerful.||In a NoSQL database, queries are focused on a collection of documents. Sometimes it is also called UnQL (Unstructured Query Language). Different databases have different syntax for using UnQL.|
|Reliability or ACID Compliancy||The vast majority of relational databases are ACID compliant. So, when it comes to data reliability and safe guarantee of performing transactions, SQL databases are still the better bet.||Most of the NoSQL solutions sacrifice ACID compliance for performance and scalability.|
|Usage||Here are a few reasons to choose a SQL database:|
* We need to ensure ACID compliance. ACID compliance reduces anomalies and protects the integrity of your database by prescribing exactly how transactions interact with the database. Generally, NoSQL databases sacrifice ACID compliance for scalability and processing speed, but for many e-commerce and financial applications, an ACID-compliant database remains the preferred option.
* Your data is structured and unchanging. If your business is not experiencing massive growth that would require more servers and if you’re only working with data that is consistent, then there may be no reason to use a system designed to support a variety of data types and high traffic volume.
|When all the other components of our application are fast and seamless, NoSQL databases prevent data from being the bottleneck. |
* Big data is contributing to a large success for NoSQL databases, mainly because it handles data differently than the traditional relational databases.
* A few popular examples of NoSQL databases are MongoDB, CouchDB, Cassandra, and HBase.
* Storing large volumes of data that often have little to no structure. A NoSQL database sets no limits on the types of data we can store together and allows us to add new types as the need changes. With document-based databases, you can store data in one place without having to define what “types” of data those are in advance.
* Making the most of cloud computing and storage. Cloud-based storage is an excellent cost-saving solution but requires data to be easily spread across multiple servers to scale up. Using commodity (affordable, smaller) hardware on-site or in the cloud saves you the hassle of additional software and NoSQL databases like Cassandra are designed to be scaled across multiple data centers out of the box, without a lot of headaches.* Rapid development. NoSQL is extremely useful for rapid development as it doesn’t need to be prepped ahead of time. If you’re working on quick iterations of your system which require making frequent updates to the data structure without a lot of downtime between versions, a relational database will slow you down.