Server-Side Scripting/Key-Value Databases

This lesson introduces key-value database processing.

Objectives and Skills


Objectives and skills for this lesson include:

  • Understand NoSQL database concepts
  • Understand key-value database concepts
  • Use a key-value database with server-side scripts


  1. Wikipedia: NoSQL
  2. Wikipedia: Key–value database


  1. YouTube: Redis NoSQL
  2. YouTube: Redis Caching



Before trying to work with any database using a programming language, you should first be familiar with that database's command language. The following tutorials will be helpful in understanding how to use Redis.



The following examples use Redis as the key-value database. A similar approach would work for almost any key-value-based database.



Complete the following activities using HTML, CSS, and a server-side scripting language. Apply best practices for user interface design and your selected scripting language, including modules, comments, indentations, naming conventions, and constants. Use HTML forms and input elements for input, server-side scripts for processing, and HTML elements for output. Use separate functions for each type of processing. Avoid global variables by passing parameters and returning results. Add comments at the top of the code modules and include references to any resources used. Add the completed code to your website as /lesson11.

  1. Create an application that allows the user to insert, update, and delete records in a key-value database. After each action, display the current records. Use any key-value database and data structure you like. Be sure to include date, text, and number field types in the data structure. If in doubt, any of the previous cyclone, earthquake, or wildfire activities may be used as data examples.

Lesson Summary

  • A key-value database (sometimes called a key-value store) uses a simple key-value method to store data. These databases contain a simple string (the key) that is always unique and an arbitrary large data field (the value). They are easy to design and implement.[1]
  • An in-memory database relies on memory (RAM) for data storage rather than disks or SSDs. It is exceptionally fast for read and write operations, but data is not persistent.[2]
  • Keys are the field used to represent a dataset in a key:value database. The key in key:value.[3]
  • A common practice is to use dots, dashes, or colons to make multi-word keys more readable, for example, “user:1000” or “poet:Dickinson”.[4]
  • Strings are the most basic type of value you can create and manage. Keys that store strings can only hold one value, but that string value can hold any type of data up to 512MB.[5]
  • Redis provides data structures such as strings, hashes, lists, sets, sorted sets with range queries, bitmaps, hyperloglogs, geospatial indexes, and streams.[6]
  • One of the data types for the values in a Redis key-value database is lists. Using a linked list of strings is an efficient operation regardless of the size of the value. The possibilities offered by linked lists make them an ideal data type for storing real-time data updates, such as social media posts or logs.[7]
  • Redis also can be used to store JSON data. It has a few drawbacks, but it is another option for Redis to store data.[8]
  • Hashes are a map between string fields and string values, this data type is best to represent objects.[9]
  • Use cases for key-value databases include: Session management on a large scale, using cache to accelerate application responses , storing personal data on specific users, product recommendations, storing personalized lists of items for individual customers, managing each player’s session in massive multiplayer online games.[10]
  • Redis persistence performs point-in-time snapshots of your dataset at specified intervals.[11]
  • Redis replication copies data to multiple Redis nodes in a cluster, which improves request performance and provides data persistence if some nodes go down, providing high availability.[12]

Key Terms


See Also



  2. AWS: In-Memory Database
  3. Tutorialpoint: Redis - Keys
  4. DigitalOcean: How To Manage Hashes in Redis
  5. DigitalOcean: How To Manage a Redis Database
  7. phoenixNAP: Redis Data Types With Commands: Comprehensive Guide
  8. "JSON Storage". Redis Labs. Retrieved 2021-04-08.
  9. Data Types
  11. Redis Persistence