Key Values Relations in NoSQL
Tags: nosql, beginners, tutorial
Published: 2022-09-11 02:18:28

In this article, we learn about the features of the key-value store in NoSQL. Before starting this topic we must know some basics of NoSQL and types of NoSQL.

NoSQL refers to a non SQL or nonrelational database that main purpose of it is to provide a mechanism for storage and retrieval of data. NoSQL database stores the information in JSON documents instead of columns and rows. As we know the relational database use rows and columns for storing and retrieval of data but in the case of NoSQL it uses JSON documents instead of rows and columns and that is why it is also known as a nonrelational SQL or database.

A [NoSQ](https://www.geeksforgeeks.org/introduction-to-nosql/)L database includes simplicity of design, simpler horizontal scaling, and fine control over availability. The data structures used in the NoSQL database are different from those we used in the relational database. the database used in NoSQL is more advanced which makes some operations faster in NoSQL.

![image1](https://cdn-images-1.medium.com/max/2000/0*XIsf0gK7qAyn0O-t.jpg)

## Why NoSQL is Used?

* Relationships present in NoSQL are less complex as compared to relational database systems.

* Actions performed in NoSQL are fast as compared to other databases.

* Implementation of it is less costly than others.

* Programming in it is easy to use and more flexible.

* A high level of scalability is provided by NoSQL.

## Types of NoSQL:

These are some of the most popular types of NoSQL as follows:

* **Document databases:** Primary operation of it is to store the information in documents.

* **Key-Value Store:** These groups associate the data in collections with records that are identified with unique keys for easy retrieval.

* **Wide Column database:** They use the tabular format yet allow a wide variance in how data is named and formatted in each row and each table. It is different from relational databases because the names and format of the columns vary from row to row in the table.

* **Graph database:** Its main aim is to use graph structures to define the relationships between data points.

## What is the Key-Value Store NoSQL?

This is a specific type of NoSQL database in which the key-value method is used and its main purpose is to represent the various key-value pairs. Here the keys are called unique identifiers for values and values can represent more than one type of object like — a string or even a string.

This is different from a relational database in such a way, key-value databases do not contain any defined structure as we know that relational databases represent data into tables and columns by which relational database has a well-defined structure and its data types are assigned to its columns whereas key-value database contains a pair of keys and values.

Think about a dictionary such as a dictionary containing various words and their meanings. so here the word in the dictionary is the key and its meaning as the values. key names can be specified from as simple as numbers to any specific descriptions of the values.

In the given below example, we have a pair of keys and values as we discussed above the on left there is a column for keys and their values are defined on the right of these keys.

![image2](https://cdn-images-1.medium.com/max/2000/0*jbelwPNdcsDm52j4.jpg)

## Features of Key-Value Store:

* **Consistency:**Consistency is a feature only applicable for operations on a single key in a key-value store. There are various implementations in the key-value store for example in RIAK, the eventually consistent model of consistency is implemented.

* **Transactions:**In it, there are no guarantees on the writes as many data stores implement transactions in different ways for example RIAK uses the concept of quorum implemented by using the W value replication factor. (RIAK is an open-source and distributed database that is generally based on a NoSQL database system.)

* **Query:**All the key-value stores can be queried by the key and that’s about it. If we have requirements to query by using some of the attributes of the column, it is not possible for using the database in this condition, our application needs to read the value to recognize if the attribute meets the conditions.

* **Scaling:** Key values are stored scale by a process called sharding. Sharding means we can support scalability by putting different parts of the data onto different servers, this is called sharding.

## Popular Key-Value Databases:

* **REDIS:**Redis is one of the popular key-value databases as it is an open-source, in-memory data structure, used as a database and message broker. REDIS supports many data structures such as lists, hashes, sets, and strings. REDIS has many more important features such as it has built-in replication and LUA scripting and it also supports LRU eviction.

* **AEROSPIKE:**It is the world’s leading enterprise-grade, internet-scale, key-value store database, it is popular for some of its advantages over other databases such as aerospike gives strong consistency, linear scalability, and higher performance as compared to others.

* **AMAZON DynamoDB:**The main reason behind the popularity of this database is that it is a fully-managed database service that provides fast performance at any scale. Many AWS customers chose DynamoDB for web gaming, mobile, ed-tech, IoT, and many other applications.