Introduction to key-value databases

Introduction to NoSQL

Jake Roach

Data Engineer

Key-value databases

Definition: A NoSQL database that uses simple key-value pairs (similar to dictionaries in Python) to store data.

  • Can be searched by key, not the value
  • Store values of type string, hash, or lists
  • Performant for simple read and writes of data
  • Data is stored in memory, instead of on disk

Key-value pair, with arrow pointing to the key.

1 https://redis.com/nosql/key-value-databases/
Introduction to NoSQL

Key-value database use-cases

Image showing a key-value database interacting with a web application.

Commonly used in web applications, for:

  • Session management
  • Caching frequently accessed data
  • Track user preferences and behavior

$$

Key-value databases source analytics platforms:

  • Snowflake
  • Redshift
Introduction to NoSQL

Redis

Redis logo.

redis library to interact with Redis using Python

$$

  • Connect to cluster running on localhost
  • Exposed over port 6379
  • Decode responses, instead of bytes
import redis

# Create a connection to Redis cluster
r = redis.Redis(
    host="localhost",
    port=6379,
    decode_responses=True
)

Later, we'll:

  • Store key-value pairs
  • Retrieve key-value pairs
Introduction to NoSQL

Let's practice!

Introduction to NoSQL

Preparing Video For Download...