Key-Value Store — NoSQL Database
The second category of NoSQL Database that we are going to discuss is key-value store.
What is key value store and how does it work?
A key-value store offers great approach for storing and accessing large quantities of unstructured data. A key-value store or key-value database uses associative array(like map or dictionary) as base data model where each key is associated with only one value in the collection. In key-value database, a string(hash or filename) is the key while value could be of any type and is stored as BLOB(Binary Large Object) which improves performance by removing need for indexing.
Key-value store provides a way to fetch, insert, delete using commands like get, put, delete which directly makes requests to object in memory.
“Sam Bonvy”: {“location”: “USA”, “shopping frequency”: “low”}
“Sam Bonvy” is the key, while {“location”: “USA”, “shopping frequency”: “low”} is the value.
The data is stored in database by put(key, value), value is fetched by get(key) and deleted by delete(key).
Need for key-value store: In today’s world, as the data is generated at a high rate, so does the need for an efficient data storage that is scalable, flexible and highly proficient at processing large streams of data.
Advantages:
- Simplicity: Quite easy to use, straightforward commands(get, put, delete) and absence of datatypes makes developers life easy
- Speed: This simplicity makes key-value database quick to respond. Simple commands makes key-value store highly proficient at processing large streams of data.
- Scalable: Scalable horizontally and vertically
- Redundancy: Built-in redundancy covers for lost storage node
Disadvantages:
- Values cant be filtered: The database sees values as black box. When value corresponding to a key is requested, the entire value is returned- rather than specific piece of required information. If specific piece of information is updated, the entire value needs to be updated.
- Cant filter based on valid field: While key-value store is simplistic, there is no straightforward means to query database with anything else apart from key.
Hence, key-value store isn’t suggested for applications requiring frequent updates, or complex queries regarding specific data values, or relationship between multiple unique keys.
Use cases:
- In web applications to store user details, preferences and session
- Product recommendation
- Works as a cache for heavy access but rarely updated data
- Analyzing customer shopping habits and providing ads real-time
Major tech-giants have built infrastructure on key-value store so as to provide high efficiency and faster speed.
Popular key-value databases are Amazon DynamoDB and Redis
The next blog will cover third category of NoSQL database i.e. graph database. Link: https://sakshi8699.medium.com/graph-database-nosql-database-26faaf24fd45
Thank you for checking out my blog! Subscribe to get notified on my upcoming blogs.