26_SQL_vs__NoSQL
26_SQL_vs__NoSQL
NoSQL
• SQL
• NoSQL
• High level dif f erences bet ween SQL and NoSQL
• SQL VS. NoSQL - Which one t o use?
• Reasons t o use SQL dat abase
• Reasons t o use NoSQL dat abase
In the world of databases, there are two main types of solutions: SQL and NoSQL
(or relational databases and non-relational databases). Both of them differ in
the way they were built, the kind of information they store, and the storage
method they use.
Relational databases are structured and have predefined schemas like phone
books that store phone numbers and addresses. Non-relational databases are
unstructured, distributed, and have a dynamic schema like file folders that hold
everything from a person’s address and phone number to their Facebook ‘likes’
and online shopping preferences.
SQL #
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. Some of the most popular relational databases are MySQL, Oracle, MS
SQL Server, SQLite, Postgres, and MariaDB.
NoSQL #
Following are the most common types of NoSQL:
Key-Value Stores: Data is stored in an array of key-value pairs. The ‘key’ is an
attribute name which is linked to a ‘value’. Well-known key-value stores
include Redis, Voldemort, and Dynamo.
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
(entities), properties (information about the entities), and lines (connections
between the entities). Examples of graph database include Neo4J and
InfiniteGraph.
NoSQL databases have different data storage models. The main ones are key-
value, document, graph, and columnar. We will discuss differences between
these databases below.
Schema: In SQL, each record conforms to a fixed schema, meaning the columns
must be decided and chosen before data entry and each row must have data for
each column. The schema can be altered later, but it involves modifying the
whole database and going offline.
In NoSQL, schemas are dynamic. Columns can be added on the fly and each
‘row’ (or equivalent) doesn’t have to contain data for each ‘column.’
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.
On the other hand, NoSQL databases are horizontally scalable, meaning we can
add more servers easily in our NoSQL database infrastructure to handle a lot of
traffic. Any cheap commodity hardware or cloud instances can host NoSQL
databases, thus making it a lot more cost-effective than vertical scaling. A lot of
NoSQL technologies also distribute data across servers automatically.
Most of the NoSQL solutions sacrifice ACID compliance for performance and
scalability.
1. 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.
2. 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.
3. 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.
Back Next
Completed