menu EXPLORE
history NEW

Key-value database

Databases are essential, today, to be able to effectively store information and data to be able to use them whenever necessary.

The first databases used the relational model. Briefly, they were based on store information in tables and establish relationships between them. Currently they continue to be used for many tasks.

However, relational databases can be slow and for this reason the non-relational databases that are much faster.

There are several types of non-relational or NoSQL databases: document-oriented databases, graph-oriented databases, columnar databases among others.

Today's article It focuses on explaining in detail non-relational key-value databases.

Stay and discover how they can help you in your next project!

What is a database or key-value store

Key-value databases are a type of non-relational database (NoSQL) that uses the key-value paradigm, a way of storing data designed to edit, retrieve and delete all types of information.

This model of defining data is used in multiple programming languages. In Javascript we have the json format, in Python we have dictionaries and in Java or C++ we have Maps.

The information is stored in what are known as hash tables, where the keys are stored with the corresponding pointers that point to the part of memory where the values ​​are located.

image database key value

It is important to establish a correct relationship between keys and values. Each key must be unique since it is related to a single value. Information can be updated using commands such as DELETE or PUT.

However, unlike relational databases that use SQL as a query language, key-value databases do not have a standardized language.

Other types of databases such as non-relational graph-oriented databases using the key-value model internally.

When to use a key-value database

It is important to have a mental scheme of when we can use key-value databases. Below we give you 3 situations where this type of database would be interesting to consider implementing.

Fast server response

Some key-value databases like Redis allow you to save information directly to RAM. This greatly speeds up the response from the server.

If you are building a project that needs a quick response then this type of database can be very helpful.

Basic data storage

These types of databases are ideal for storing basic information that fits the key-value model. Some examples are user information, data from a purchase in an online store, product categories, among others.

Applications that do not need constant updates

Another example is for applications that need to store data for a long time without updating it and that do not need complex queries or that involve relationships.

Examples of key-value databases

There are several options when choosing a platform such as a key-value database. Below we give you 3 examples so you know where to start. Later you can learn more about each one to see which one interests you most for your projects.

Redis

The name Redis comes from Remote Dictionary Server and it is a database that uses the key-value model to store data. It is written in Ansi C although it can be used by the most popular programming languages ​​such as Python, Java or PHP.

Redis bases its storage on a hash table structure where each key has an associated value. The data types that Redis allows are: lists, text strings, sets, and ordered sets.

DynamoDB

DynamoDB is a type of key-value database available on Amazon servers (AWS). DynamoDB is programmed to facilitate horizontal scalability by applying distributed computing methods.

It integrates very well with other Amazon services such as storage systems such as S3 or with Kinesis for streaming data analysis.

Unlike Redis, DynamoDB is paid and applies a price for different writing, reading or backup generation operations.

Aerospike

Aerospike is another key-value NoSQL database designed to be flexible and scalable. Just like DynamoDB uses distributed computing to improve handling of large amounts of data.