dot Become a Redis expert.

See what's new in Redis University

A Guide to Understanding JSON Databases

How do JSON databases function, and what value do they bring to application developers? Maybe examples from a pet cat’s point of view can put things into perspective.

Let’s start out by defining the terms. And the cat.

What is JSON?

Whether developers are creating business logic, user interfaces, databases, or backend systems, they need a way to describe and exchange data. One system says to another, “I have the data you need!” and they need to structure how data is exchanged. The data exchange may be using binary data, or it may be text-based. 

JavaScript Object Notation (JSON) is a text-based data interchange format native to JavaScript. Because it is text, it is readable by both people and machines. JSON is commonly used to store and transmit data to applications.

Like XML, JSON is a data interchange format rather than a programming language, in the sense that it is not Turing-complete. But, also like XML, in some ways it can be used as though it’s a programming language because of its readability and power. As JSON.org explains, JSON “uses conventions that are familiar to programmers of the C-family of languages,” such as Python and Java. That makes JSON a comfortable tool to use for sharing data among platforms.

JSON has a dual structure: 

  • key/value pairs, sometimes described as “name/value pairs,” and 
  • a list of values in a particular order

A JSON value can be an object, keyed list, record, dictionary, associative array, string, number, true, false, or null

For example, suppose the key in question is a kitten; its value is floofy. Together, these two make up an object, as long as the object is surrounded by curly braces. (The cat can be surrounded by whatever it likes.) A full JSON string describing this kitty might look like:

{"name": "Jason", "age": 1, "floofy": true}

In this example, the attributes on the left, such as name, age, and floofy are the keys in question, while Jason, 1, and true represent the values.

Ready to see how Redis Enterprise native JSON allows developers to build modern applications?  Read more about Redis JSON.

What are JSON databases?

A JSON database (alternately spelled JSON db) is a document database, sometimes called a document store. The data is expressed in text-based documents rather than in the column or tabular form you may be familiar with from SQL databases.

Structurally, a JSON database is a NoSQL database that reads and stores semi-structured data using JSON documents, such as a PDF, a document, or an XML or JSON file. Column, graph, key-value, in-memory, and document are all different types of NoSQL databases.

JSON databases have significant advantages

  • JSON data is human-readable. Anything that makes it easy for humans to understand is valuable – and more so given the ease by which data in JSON databases can be parsed.
  • JSON is lightweight. It has little formatting overhead (compared to XML, which is chatty). That can be meaningful in the amount of bandwidth needed to transmit data or store it.
  • Developers can establish data relationships in a self-documenting fashion. In the cat example above, you need to do only one query to get the data for both the name field “Jason” and the cat’s value “floofy”. That can offer a performance boost as well.
  • JSON databases (like other NoSQL databases) don’t require a particular data structure in order to package data. When an application’s data model changes, you don’t need to fully reorganize the databases on which the software relies.

The advantages extend beyond the user-friendliness of its data structure. From storage, schema, and indexing flexibility, to horizontal and vertical scaling, here are some ways JSON databases simplify developers’ lives. 

Storage flexibility

One important element in JSON databases is that they are dynamic. SQL databases have fixed field definitions and field sizes, so restructuring a database requires reindexing and other complexities. JSON databases are far more flexible because the key/value structure can adapt to changes in the data model or application requirements. 

Imagine a web application that depends on user profiles and login authentication. A JSON database’s key value can store the user IDs, user preferences, multiple ID mappings, and additional information so that the app can quickly look up a user and authenticate access. If the application requirements change – perhaps it’s important to include geographic data for compliance reasons – the database schema can change without a complete overhaul.

Schema flexibility

A JSON document database is a compact arrangement of stored data with a flexible structure that the developer defines. The leanness of a JSON file greatly accelerates the speed by which the data interacts with the application.

A JSON database schema permits objects to be embedded or linked, including circular references. The earlier example, introducing Jason the cat, intentionally is “hello world” simple. However, JSON can also model complex data structures such as object graphs and cyclic graphs. In particular, JSON databases support nesting, object references, and arrays. That gives developers clarity, because it decouples objects into different layers, making the database easier to maintain.

With nested JSON database schemas, some values are other JSON objects.

{
 "pet": {
   "name": "Jason",
   "age": 1,
   "location": "USA",
   "kur": "long-haired",
   "breed": "Persian",
   "Address": {
     "longitude": "-113.6335371",
     "latitude": "37.1049502",
     "postal code": "90266"
   }
 }
}

Partitioning data

High-performance computing requires databases to scale to meet demand, in both the long-term (supporting huge data sets) and the short-term (holiday shopping periods during which everyone buys more cat toys). Horizontal scalability, a way to perform load balancing to prevent one node from bearing the brunt of everything required, works particularly well with JSON databases. That’s because it’s possible to partition JSON data and indexes over several shards and nodes for improved speed and memory management.

Big data analytics

JSON databases have become extremely popular in data science and analytics applications. These demanding big data applications benefit from JSON databases’ horizontal architecture and support for multiple concurrent queries. 

That’s because of JSON databases’ flexible schema and horizontal and vertical scaling. These enable document databases to store large datasets and to add more nodes when needed. Partitioning allows the data to be balanced across the nodes to increase the speed of reads and writes and to ensure availability.

Supports different index types

Indexing is a strategy for retrieving data. Document databases support all kinds of indexes, such as sorted sets, lexicographically encoded, geospatial, IP range, full-text search, and partitioned indexes.

Redis Enterprise JSON in action

To see a real-time JSON demonstration, Redis’ Justin Castilla’s fun live stream, “Do Birds Dream of JSON,” illustrates how to search and extract information from huge banks of information. He uses data from bird sightings to highlight the capabilities of JSON – without, alas, a cat to supervise the birds. 

https://www.youtube.com/embed/XkzSHMLYN1Q

Looking for JSON support? 

If you need more information on how JSON functions, our YouTube channel has a wide array of live streams, how-to videos, and webinars on this popular data notation format. Visit our channel anytime you run into a dead-end. We usually have a visual answer to guide you.

FAQ

  • What is a JSON database?
    • JSON databases are non-relational NoSQL databases that store unstructured data as structured JSON documents, as compared to e SQL databases, which use tables consisting of rows and columns to structure data.
  • What is an example of a JSON database?
  • What database is best for JSON?
    • Document databases composed of JSON files are one of the five types of NoSQL; it already has a JSON structure. In this kind of non-relational database, the JSON object can be modified within the document store. A SQL server will likely support JSON data type, but is likely to come with more restrictions on how the data can be parsed and structured. In the end, this is typically dependent on your use case.
  • What are some JSON use cases?
    • JSON databases are used in web and mobile application development, online session stores and shopping baskets, gaming leaderboards and user inventories, data interchange and storage, NoSQL databases, content management systems, and real-time data exchange in IoT applications.