Video
Learn more
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.
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:
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.
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.
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.
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.
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"
}
}
}
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.
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.
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.
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.
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.