Chapter 2. Key-Value Stores
In a key-value store, the information items are formed by key-value pairs like the phone number directory entry ⟨"Bob", "(732) 516-8970"⟩ or the English-German translation table row ⟨"my car", "mein Auto"⟩.
Well-known key-value store management systems are Redis, Oracle Berkeley DB and the localStorage that is built into the Web programming language JavaScript.
The key in a key-value pair must be unique. Normally, keys are strings. But a key-value DBMS may allow any value supported by the DBMS (strings, numbers, object references, etc.) to be a key. Normally, the value in a key-value pair may be any value supported by the DBMS.
As a first example of a database, we show how to deal with key-value pairs and how to manage a key-value store using JavaScript, which provides a built-in object called localStorage
that allows storing a key-value pair in the following way:
localStorage["Bob Jennings"] = "(732) 516-8970";
JavaScript programs are loaded and executed in the context of a webpage defined with HTML (the ). In our key-value store project, we embed the JavaScript code within the HTML files index.html, add.html, update.html, and delete.html, corresponding to the data management operations Retrieve/List All, Create/Add, Update and Delete. All of these HTML files contain the same navigation menu (in a nav
element), allowing to go to any of these pages for performing the corresponding data management operation.