IndexedDB: concepts (part 1)

IndexedDB

Introduction

IndexedDB logo

IndexedDB is presented as an alternative to the WebSQL Database, which the W3C deprecated on November 18, 2010 (while still available in some browsers, it is no longer in the HTML5 specification). Both are solutions for storage, but they do not offer the same functionalities. WebSQL Database is a relational database access system, whereas IndexedDB is an indexed table system.

From the W3C specification about IndexedDB: “User agents (apps running in browsers) may need to store large numbers of objects locally in order to satisfy off-line data requirements of Web applications. Where WebStorage (as seen in the HTML5 part 1 course -localStorage and sessionStorage) is useful for storing pairs of keys and their corresponding values, IndexedDB provides in-order retrieval of keys, efficient searching of values, and the storage of duplicate values for a key“. 

The W3C specification provides a concrete API to perform advanced key-value data management that is at the heart of most sophisticated query processors. It does so by using transactional databases to store keys and their corresponding values (one or more per key), and providing a means of traversing keys in a deterministic order. This is often implemented through the use of persistent B-tree data structures which are considered efficient for insertion and deletion, as well as for in-order traversal of very large numbers of data records.

To sum up:

    1. IndexedDB is a transactional Object Store in which you will be able to store JavaScript objects.
    2. Indexes on some properties of these objects facilitate faster retrieval and search.
    3. Applications using IndexedDB can work both online and offline.
    4. IndexedDB is transactional: it manages concurrent access to data.

Examples of applications where IndexedDB should be considered:

google drive uses indexedDB

    • A catalog of DVDs in a lending library.
    • Mail clients, to-do lists, notepads.
    • Data for games: high-scores, level definitions, etc.
    • Google Drive uses IndexedDB extensively…

External resources

Much of this chapter either builds on or is an adaptation of articles posted on the Mozilla Developer Network site (IndexedDB, Basic Concepts of IndexedDB and Using IndexedDB).

Current Support

Current support is excellent both on mobile and desktop browsers (as of December 2018).

IndexedDB support

Click to see an up to date version of this table

Leave a comment