Non-tabular databases (sometimes known as "not only SQL") store data differently from relational tables. NoSQL databases are classified according to their data model. Document, key-value, wide-column, and graph are the most common types. They have adaptable schemas and can handle big amounts of data and high user loads with ease.
There are four types of NoSQL databases: key-value pair, column-oriented, graph-based, and document-oriented. Each category has its own set of characteristics and limits. None of the databases listed above is better at solving all of the difficulties. Users should choose a database that meets their product requirements.
Document databases store and retrieve data from documents using key-value pairs. XML and JSON are both used to store documents.
For speedier querying, the Documents can be nested and indexed.
Developers can restructure their Documents using document databases based on their application requirements, which may vary over time. Database administrators in the RDBMS industry, on the other hand, are required to restructure database structures.
MongoDB, OrientDB, Apache CouchDB, IBM Cloudant, CrateDB, BaseX, and other document databases are examples.
The relationship between data components is the emphasis of a graph database. Every element is represented by a node (such as a person in a social media graph). The term "links" or "relationships" refers to the connections that exist between items. Connections are first-class database elements in a graph database, and they are stored directly. Links are inferred in relational databases, which use data to express relationships.
A graph database is designed to capture and search the relationships between data pieces, avoiding the complexity of SQL JOINing numerous tables. Only a small percentage of real-world business systems can rely completely on graph queries. As a result, graph databases are frequently used in conjunction with other types of databases.
Fraud detection, social networks, and knowledge graphs are examples of use cases.
Example:-
For example, In the above diagram, we can see the Twitter network which defines the nodes as Hashtag, Link, Tweets, users. Graph databases are ideal for applications that need to traverse paths between entities or query the relationship between entities and their properties.
Features of a Graph-based database:
It is much more flexible.
It provides agility.
It even provides better performance with larger volumes of data.
Typical use cases for graph databases would include social networking sites, recommendation engines, and so forth.
The only disadvantage is that it is difficult to scale out.
Key-value Pair-based
The simplest type of NoSQL database among the four types of databases is the key-value store. The data is stored using keys and values. The name of the attribute is kept in 'key,' while the values for that key are kept in 'value'.
The key in a key-value store database can only be a string, whereas the value can be a string, JSON, XML, Blob, or any other type of data. It can handle large amounts of data and loads due to its characteristics.
User preferences, user profiles, shopping carts, and other data are stored in key-value stores.
Key-value store NoSQL databases include DynamoDB, Riak, and Redis, to name a few.
Example:-
Key
Value
Id
12
Name
Ram Sharma
Age
23
Features
It provides consistency.
Transactions are possible here.
Provides Query Features.
Data Structure.
Provides Scaling.
Advantages
Simple Data Model.
It is Scalable.
Its values can include JSON,XML,and flexible schemas.
It is extremely fast compared to others.
It's best for situations where the data isn't all that closely related.
Disadvantages
Don't have scanning capabilities.
Not much useful for operations other than creating, reading, updating, and deleting (CRUD).
Not good for complex data.
You have to create your own foreign keys.
Column-oriented graph
Data is stored in a series of columns known as column families in column-oriented databases. This means that if a user only needs to perform queries on a small number of columns, they can read those columns directly instead of utilizing all of the data's memories. The Column-oriented database is built on the notion of Google's BigTable publication.
Column-based databases such as HBase, Cassandra, HBase, and Hypertable are instances of NoSQL queries.
Column Family
Row Key
Column Name
Key
Key
Key
Value
Value
Value
Column Name
Key
Key
Key
Value
Value
Value
Advantages
It is scalable.
It is naturally indexed.
It also supports semi-structured data.
Its only disadvantage is that it is not suitable for relational data.
Which database is naturally indexed among the NoSQL databases? The column-oriented database is naturally indexed from the four types of databases mentioned above.
Why is the Key-Value database preferred over Document oriented databases? Key-Value database is preferred over Document database because it is extremely fast, provides consistency, and also provides Query Features.
Which database should be used when dealing with a large amount of data? When dealing with a large amount of data Graph-based datatype should be used because of its flexibility, it provides structure to the data and it is extremely powerful.
Key Takeaways
So now we have learned about the types of NoSQL databases and about their advantages over each other. We can use these types of databases. Hope you learned something. But the knowledge never stops, so to better understand the Database management system, you can go through many articles on our platform.
Don't stop here, Ninja; check out the Top 100 SQL Problems to get hands-on experience with frequently asked interview questions and land your dream job.