Non-relational databases are also known as non-relational database management systems or NoSQL(not only SQL). They are non-tabular. There are four major types of NoSQL databases: document, key-value, wide columns, and graph databases.
Document Databases
Stores data in a document. A document is a container for key-value pairs. The document is stored in JSON or XML format. They are unstructured and don’t require a schema. The documents are grouped together into collections. The collections can be organized into a hierarchy allowing you to model and retrieve relational data to a significant degree without joins. They are mainly suited for Online games, IOT, mobile apps, etc. The most popular ones are Firestore, DynamoDB, CouchDB, and MongoDB.
Key-Value databases
Store data in a format where each item contains keys and values. They store data in a hash table where each key is unique just like in dictionaries and the value can be JSON, string, BLOB(Binary Large Object), etc. Key-Value data stores mainly store data in memory and not the disk. This limits the data you can store but makes it extremely fast. A good example is Redis or Memcached. They are mainly used for data caching.
Wide-Column Database
A wide-column database, also known as a column-family database, is a type of NoSQL database that organizes data into tables with rows and dynamic columns. This allows for more flexible and efficient storage of large amounts of unstructured data, as well as faster querying and retrieval of specific data subsets. Examples of wide-column databases include Apache Cassandra, HBase, and Amazon SimpleDB.
Graph Databases
Stores data in nodes and edges. The nodes typically store information about people, places, and things while edges store information about the relationship between the nodes. They are a good alternative to relational databases especially when you require to make a lot of joins and performance is taking a hit. Graphs are useful when identifying patterns between structured and semi-structured data. They are mainly used in fraud detection in finance and to power recommendation engines like AirBnB. Popular ones are neo4j and Dgraph.
When do you use NoSQL databases?
NoSQL is designed to address the major issues in relational databases. NoSQL can be used across large distributed systems since they are more scalable and can handle more data loads compared to relational databases. NoSQL databases are the right choice if:
Your application requires super low latency - Access is very fast in Key/Value stores which provides low latency and high throughput.
Your data are unstructured, or you do not have any relational data.
You need to store a massive amount of data.
Benefits of NoSQL database
Flexibility - Relational databases strictly store data in a structured format. NoSQL provides support to flexible schemas that enable faster development. The flexible data model is perfect for unstructured and semi-structured data. NoSQL databases allow developers to change the structure of data without disrupting the current structure.
Scalability - Relational databases are mostly implemented using scale-up architecture which means you increase computer performance by upgrading CPUs and adding more memory. Non-relational databases, on the other hand, were designed to scale out by using distributed clusters of hardware. The scale-out architecture makes NoSQL easily scalable when data and traffic grows.
Simplicity and Developer-friendly - Many NoSQL databases are simple and developers find it easier to create various types of applications compared to NoSQL.In addition, NoSQL store data in forms that are close to data objects therefore fewer transformations are required when moving data in and out of the databases.
Large amounts of data storage - Many NoSQL databases can handle large data sets making them perfect for big data applications. NoSQL is great when you are dealing with large volumes of data.
Limitations of NoSQL database
The lack of SQL - A major complaint about NoSQL is that it does not come with SQL which is a mature technology for querying databases. They lack the complex tool functionality found in SQL.
Lack of Standardization - Every NoSQL database uses its own schema. In such databases as MongoDB, there is no schema. It is dynamic in some other databases like ElasticSearch. Some other database designs resemble relational databases(for example Cassandra). The problem here is that each database has its own unique strengths and weaknesses which must be learned before choosing the right database for a project.
The lack of ACID - We discussed ACID as the properties that define a transaction. NoSQL does not support these properties. Transactions provide the strongest guarantees available around data consistency.