Guide to Key-Value Stores – NoSQL Explained

 

The information world has changed. Those neatly packaged rows and columns of conventional relational databases are no longer the be-all and end-all of data management. In this cyber-age, NoSQL databases now go boldly where relational databases cannot; yet where businesses and users must. NoSQL (or in fact, ‘NoRel’ for ‘not only relational’) databases are Big Data friendly. They can handle the huge amounts of semi-structured or unstructured information that are becoming available. Out of the four main types of NoSQL databases currently defined (key value, wide column, document and graph), key value databases in particular distinguish themselves in two ways.

Key Value Store Speed

Firstly, a NoSQL key value database or store is fast, much faster than a comparable relational database. Its speed comes from its simplicity. A key value database stores a data record using one primary key. The key means the record is uniquely identifiable. However, the key value database ignores the kind of data that is being stored. It’s up to the application handing over or retrieving the data to figure out how to deal with the data records. Because of this simplicity, data saves and lookups in a key value database can be very fast: each operation only needs one hard disk access, compared to multiple accesses for other database systems.

Great Scalability – What About Consistency?

Secondly, a NoSQL key value database is also highly scalable. This too is a function of its simplicity. Unlike a relational database, a NoSQL key value database is not obliged to scale vertically. It can scale over several machines or devices by several orders of magnitude, without the need for significant redesign. Financially, this is a big advantage too. Scaling a relational database solution often means that cost increases dis-proportionally; it also requires time and effort (and server downtime) to change your database schema. By comparison, a key value database keeps the price curve linear rather than exponential, and it is designed to handle data without any predefined schema. Some (not all) key value databases, like other NoSQL databases, are also designed for ‘eventual consistency’. This means that data are synchronized ‘at some point’ between copies on different machines, but not immediately.

Schema-Free Rows and Columns

The name Row Store is also sometimes used for a key value database. This is because all the data for a single record can be envisaged as being in a row. Looking at it this way invites comparison with another kind of NoSQL database, which is the wide column store. This kind of NoSQL database stores data in records too, but with the additional capability of holding large numbers (billions) of dynamic columns. It might sound like we’re moving back to a fixed-schema relational database model, but the wide column store is schema-free. It’s more appropriate to think of a wide column store as a two-dimensional key value store.

Applications

Where then are key value databases used today? In a general sense, they find applications in situations where a lot of schema-free data needs to be stored and accessed fast, but where a small amount of data loss may be acceptable. Managing session information in web applications is a good example. Visitors filling their shopping basket in e-commerce sites may from time to time see that a product they thought they’d put in their basket ‘fell out’. As long as this is the exception, rather than the rule, such minimal data loss may be acceptable. However, it highlights the fact that relational databases despite being relatively cumbersome continue to have an important role to play when data loss is unacceptable.

Examples of Key Value Database Products

Popular key value database products available today include Memcached, Redis and Riak. These three solutions are all Open Source, although they have slight differences in their approach to schema-free database management. Memcached and Redis are both ‘in-memory’ key value stores, whereas Riak is positioned as a distributed, fault tolerant key-value store (albeit with eventual, rather than immediate consistency). Riak runs on Linux and Mac OS X, but for a Windows solution, you’ll need to use Memcached, Redis or another key value database offering.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>