Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Understanding Key-Value stores

I'm trying to wrap my head around Key-Value stores like CouchDB and Cassandra. I understand why they're useful but as far as how they replace a RDBMS like MySql, I don't get it.

Let's say this is my what I need to store:

{123456: {'model' : 'Ford'
          'color': 'blue'
          'MPG': 23}}

Then I need to find all the cars that are blue.

How does the Key-Value store query the keys using the value? I read some where that map-reduce may be used but looking at the source of a few projects I can't find an example.

Let me know if I'm asking the right question.

like image 729
user142006 Avatar asked Oct 23 '09 13:10

user142006


People also ask

What are key-value stores good for?

Key-value stores are good for simple applications that need to store simple objects temporarily. An obvious example is a cache. A less obvious example is to use Redis lists to queue units of work with simple input parameters.

Which is the best example for key-value store?

Amazon DynamoDB: Probably the most widely used key-value store database, in fact, it was the research into DynamoDB that really started making NoSQL really popular. Aerospike: Open-source database that is optimized for in-memory storage.

How are key-value stores implemented?

The Key-Value store is the simplest of the NoSQL databases that are used in almost every system in the world. It can be as simple as a hash table and at the same time, it can also be a distributed storage system. And A Key-Value store is implemented by different data structures.

What is the main difference between key-value stores and document stores?

Document databases organize documents into groups called collections, which are analogous to the tables in relational databases. By contrast, key-value databases store all key-value pairs together in a single namespace, which is analogous to a relational schema.


1 Answers

Essentially, when you are using key-value stores, you are building a database out of the same components that a relational database has internally. The reason for doing this is to have more control and flexibility over scaling and performance, or just for straightforwardness.

In this case, you need to store the equivalent of the table rows and the index as two separate things. So if you want to index on color, then you need to store

{'blue': {123456}}

in the equivalent of an index table.

Of course, some key-value stores provide indexing and searching mechanisms for you so there is no general rule that fits all.

like image 159
Michael Dillon Avatar answered Nov 25 '22 01:11

Michael Dillon