NoSQL

For many decades we have been using traditional database systems, Relational Database Management Systems (RDBMSs). Dr. E.F. Codd is known as the father of RDBMS. The idea of the relational model came with E. F. Codd's 1970 paper "A relational model of data for large shared data banks" that made data modeling and application programming much easier. We use the Structured Query Language (SQL) for RDBMSs. RDBMSs are a schema-based database. That means there is a schema enforced by the database themselves.

attribute
Each relational database follows the ACID rules. These ACID rules ensure that each transaction must be atomic, consistent, isolated and durable. Here we have discussed the following four points:

NoSQL

NoSQL

A NoSQL database is called a Not Only SQL. NoSQL is an approach to data management and database design that's useful for very large sets of distributed data. NoSQL is different from traditional relational database management systems in some significant ways. It is designed for distributed data stores where very large scale of data storing needs. For example Google uses BigTable, Twitter uses FlockDB and Facebook uses Cassandra. BigTable, Cassandra and FlockDB are a type of NoSQL database.

NoSQL is also called a Cloud database. It is designed for 21th century web estates. In NoSQL databases we don't require any fixed schema. In other words, it is a schema-less database technique. It works on a scaling out approach instead of scaling up approach. NoSQL databases are designed to solve the scalability, big user and big data performance issues that we encounter in relational databases. NoSQL databases are useful when an organization or enterprise needs a massive amount of unstructured data that is stored on several remote virtual servers in the cloud. In general, NoSQL databases have become the first alternative to relational databases, with scalability, availability and fault tolerance being key deciding factors.

The following are some Important points about NoSQL databases:

Why NoSQL Database

Now we understand the 10 points of why NoSQL is better than SQL.

Big User

Big User

Many organizations like Facebook, Google, Yahoo, Twitter have millions of users. But the amount of userd is not constant. It other words, sometimes millions of users become active and sometimes only a thousand users are active. So the numbers of users are consantly changing. Supporting large numbers of concurrent users is important, but because app usage requirements are hard to predict, it's just as important to dynamically support rapidly growing (or shrinking) numbers of concurrent users.

So due to the inconsistent numbers of active users we should have a more easily scalable database technology. Using the relational database technique, we can't achieve dynamic scalability. It also important that during achieving this approach the performance of an application must be maintained. So we can use NoSQL for this purpose.

Big Data

Big Data image

Big Data is one of the key forces driving the growth and popularity of NoSQL for businesses. Due to the explosive growth in internet usage, each time a bulk of data is generated. This data is generated by computers, mobiles, social apps and machine-to-machine communication. Let us see a simple example. A commercial flight generates approximate 10 GB of data per hour during its travel. According to the IDC estimate until 2013 the size of the world's digital data is 4.4 zettabytes (4.4 trillion gigabytes) and it will become 44 zettabytes in 2020.

We can define big data in the following terms.

big data

So developers want a highly flexible solution that can handle big data. We can't do this with schema-based relation databases. So NoSQL is a perfect solution for handling big and schema-less data.

Continuous Data Availability

Continuous Data Availability

At the present time the continuous availability of data is very important. The downtime of a few seconds can generate a huge loss in business and a company's reputation. The best solution to avoid this is to use a distributed approach. NoSQL also works on a distributed approach. In a distributed approach we remove dependency from a single machine and spread it out on several machines. If one or more database servers or "nodes" go down then the other nodes in the system are able to continue with operations without data loss. NoSQL databases work on a distributed approach so a NoSQL database is able to provide continuous availability whether in single locations, across data centers and in the cloud.

Dynamic Schema

Relational database systems require a schema to be defined before inserting any data. For example, if we want to insert information about an employee like his name, salary and age then we first must define three columns in the table and then their data types. But this approach is not suitable in a present-time application. Because we don't know what type of data will come from the user end and how much In the future, if we are required to change the schema of the database then it will become very difficult and make work for the developer . If database is very large then it will generate downtime of system. There's also no way, using a relational database, to effectively address data that's completely unstructured or unknown in advance.

NoSQL databases are different from relational databases. NoSQL are schema-less databases so we are not required to define a schema. We can make changes in the database without worrying about service interruptions. In other words NoSQL makes development faster.

Integrated Caching

Some products provide a caching tier for relational database systems for reading the data. So it increases only the read performance. But these products don't provide any caching for writes. So if our application is predominately read-only then we can use a distributed cache but if our application is either predominately write or read-write then we cannot use a distributed cache.

NoSQL has an integrated cache capability for both read and write. We can keep frequently-used data in system memory as much as possible and eliminates the need for a separate caching layer that must be maintained.

Cloud Computing

Cloud Computing

Toady each new application uses cloud storage, either directly or indirectly. This cloud may be public, private or hybrid. All cloud applications use a three-tier internet architecture. In this architecture the application is accessed through a web browser or a mobile application. A load balancer is responsible for incoming traffic. Load balancing uses a scaling-out approach to handle the incoming traffic. In a scaling-out approach we add a new commodity server when traffic increases. But in a relational database we use a scaling-up approach instead of scaling-out. This makes them a poor fit for applications that require easy and dynamic scalability.

Because NoSQL uses a scaling-out approach and relational databases use a scaling-up approach, NoSQL is a better fit with the highly distributed nature of the three-tier internet architecture.

Scaling Out Approach

Scaling means upgrading the existing hardware without changing much of the application or by adding extra hardware. Due to an increase in concurrent users or volume of data, databases need to scale. There are two ways to achieve scale mechanism 1. Scale Up 2. Scale Out:

Replication

Data replication is the concept of having data, within a system, be geo-distributed, preferably through a non-interactive, reliable process. In traditional RDBMS databases, implementing any sort of replication is a struggle because these systems were not developed with horizontal scaling in mind. Most of NoSQL database support automatic replication. In other words we get high availability of data and disaster recovery without adding any external applications.

Auto Sharding

Auto Sharding

NoSQL has a main advantage that the data is spread across servers without effecting the performance of the application. Any server can be added or removed without application downtime. A well-established and configured NoSQL database never becomes offline. In other words, it provides 24x365 services.

Sharding in relational databases can reduce the capacity to perform complex queries. But NoSQL always retains its query expressive power even though system contains hundreds of servers.

The Internet of Things

The Internet of Things

Machine-generated data has a big presence in big data. The Internet of Things extends internet connectivity beyond traditional devices like desktop and laptop, smartphones and tablets to a diverse range of devices and everyday things that utilize embedded technology to communicate and interact with the external environment, all via the Internet. Some examples of IOT are fire extinguishers in the building, connected security systems, thermostats, cars, electronic appliances and lights in household and commercial environments. All these devices are connected to the internet and generate data each time. Approximately 20 billion devices are connected to the internet and these devices generate data from their 50 billion sensors.

Data generated by IOT are mainly semi-structured or unstructured and that poses a challenge for relational databases because relational databases work on a fixed schema and structured data.

To overcome all these problems an inventor uses a NoSQL database to store the data to improve performance.

Types of NoSQL Database

NoSQL databases can be categorized into four types, each has their own specific attributes.

NoSQL database

Key-Value Database

This is the simplest NoSQL database. In this database each item is stored with a key. The user can search or delete data using this key value. This key is like a primary key. It can't be a duplicate. Examples of this type database are Azure Table Storage (ATS), DyanmoDB, Riak and Redis.

Let us see an example.

Key Value Database

Column Type Database

In column type databases we store data as sections of columns of data, rather than as rows of data. It is also known as wide-column stores. Column type databases offer very high performance and a highly scalable architecture. For example Cassandra and HBase.

Column Type Database

The preceding data will be stored in the following form.


Graph Database

These databases are designed for data whose relations can be represented as a graph and has elements that are interconnected, with an undetermined number of relations among them. Graphs store databases used to store information about networks, such as social connections. For example Neo4J and HyperGraphDB.

Graph Database

Document Database

In a document database the data is stored as a document. Each document contains a unique key. The document can contain many key-value pairs, key-array pair or even a nested form. These are designed for storing, retrieving and managing document-oriented information, also known as semi-structured data. For example MongoDB and CouchDB.

Document Database

The following table provides basic information about the properties of each database type.

Database type

The following table provides some names of the various types of databases.

different type of Database

Disadvantages of NoSQL

NoSQL has the following disadvantages.

Difference between SQL and NoSQL

Now we consider some major differences between SQL and NoSQL databases.

Conclusion

Its never means that NoSQL is replacing relational databases. NoSQL is developed to handle the huge amount of data that cannot be handled by relational types of database in a proper way. We are entering an era of polyglot persistence, a technique that uses various data storage technologies to handle varying data storage needs. NoSQL is a rising technology in the field of databases. It requires large improvements. But it is making it easy to handle the huge amount of data that is be generated each second.