What Is a NoSQL Database?

In 1979, Relational Software, Inc. released Oracle Version 2, the first commercially available Relational Database Management System (RDBMS). Oracle Version 2 ran on the minicomputers of the day and was managed via the Structured Query Language (SQL), freeing companies from IBM mainframes and proprietary databases that lacked common standards.

By 1983, Relational Software's product had become so prominent in early enterprise tech stacks that the company changed its name to Oracle. The relational database model and the SQL language had also become standards by that point. But by the early 2000s, it was the era of Big Data and Web 2.0, and a new breed of apps was pushing the limits of SQL databases.

An RDBMS and SQL require data to be structured for optimal performance. However, enterprise architects and developers now had a large volume of unstructured data to work with, including social media posts, user activity logs, IoT sensor data, and product catalogs. The relational model was meant to scale vertically, but distributed applications with terabytes or even petabytes of data scale horizontally. An RDBMS provides consistency and durability, but high availability and speed were suddenly higher priorities. These changing needs gave rise to the NoSQL database.

What Is NoSQL, and How Is It Different From SQL?

A relational database stores information in tables comprised of rows and columns, and SQL queries are based on the relationships between the tables and the data they contain. For optimal performance, data is normalized, a schema design meant to reduce duplication and ensure consistency. However, the sheer volume of unstructured data in use across Web 2.0 and enterprise apps by the mid-2000s made the constant cycle of schema updates and normalization a serious bottleneck. It was in this milieu that the first NoSQL databases emerged.

A NoSQL database handles data storage and retrieval through means other than the tabular relations and SQL language of relational systems. For certain types of unstructured data, NoSQL databases offer these advantages:

  • Flexible or schema-less data models: Records do not have to conform to standard table schemas, which allows flexible storage of unstructured or rapidly changing data.
  • Horizontal scaling: NoSQL systems are designed to fan out across multiple servers, making them the ideal choice for distributed databases.
  • Fault tolerance: Data in NoSQL databases is often replicated and partitioned across multiple nodes, so it remains available when a single server fails.
  • Relaxed consistency: Whereas most relational systems guarantee ACID (Atomicity, Consistency, Isolation, Durability) compliance, NoSQL systems often follow the more flexible BASE (Basically Available, Soft state, Eventually consistent) model.

The term "NoSQL" was originally a reference to the lack of support for SQL queries. Over time, however, it has become clear that SQL databases still have their place, and that NoSQL serves different needs. Therefore, the term has evolved to mean "Not only SQL."

Here's an overview of how relational and NoSQL databases differ:

Relational (SQL)NoSQL
Data modelTables with rows and columnsKey-value, document, column, or graph
SchemaFixed, defined up front (schema-on-write)Flexible or dynamic (schema-on-read)
ScalingPrimarily vertical (scale up)Primarily horizontal (scale out)
ConsistencyStrong ACID transactionsOften eventual consistency (BASE)
Query languageStandardized SQLVaried APIs and query languages
Best forStructured data, complex joins, transactionsLarge-scale, unstructured, or rapidly evolving data

Types of NoSQL Databases

Since NoSQL encompasses a wide range of data structures, various database types have emerged to support common ones. This includes:

Key-Value Stores

Key-value stores are the simplest, most performant type of NoSQL database. They store data as a collection of unique keys, each mapped to a specific value or object, with the database engine having no inherent knowledge of the data's internal structure.

Due to their simplicity, key-value stores offer very low latency and high throughput for basic read/write operations. This makes them ideal for session management, real-time caching, and other scenarios where speed is the top priority. Popular key-value stores include Valkey/Redis, Amazon DynamoDB, and Riak.

Document Databases

Document databases store information in semi-structured formats such as JSON, BSON, or XML, which allows for highly flexible, nested data modeling. Unlike relational databases and their strict schemas, document stores empower developers to evolve their data structures alongside their application code. This is accomplished by allowing each document to hold different fields.

The flexibility of document databases makes them a good fit for content management systems, product catalogs, and user profiles — data with structure that's subject to frequent change and can vary across records. MongoDB and CouchDB are among the leading document databases.

Wide-Column Stores

Wide-column stores organize data using familiar rows and columns, but unlike traditional relational systems, they allow each row to have a different number of columns. In addition, columns can be grouped into "column families," so this type of NoSQL system is often called a "column-family database."

The main advantage of wide-column stores is the ability to handle exceptionally large datasets across distributed clusters. They are often the database behind high-velocity logging, IoT telemetry, and large-scale big data analytics platforms. Among the most widely used wide-column stores are Apache Cassandra, Apache HBase, and Google Bigtable.

Graph Databases

Graph databases are optimized for data where the relationships between entities are just as important as the data itself. Unlike an RDBMS, where relationships are established through expensive joins across tables, graph databases store information as nodes (entities) and edges (the relationships between them).

This unique structure allows the database to traverse complex webs of data (such as social media networks, recommendation engines, and fraud detection systems) with extreme efficiency. Neo4j and Amazon Neptune are well-known examples of graph databases.

Use Case: Valkey/Redis as a NoSQL Key-Value Store With Redisson

The in-memory data store Redis has long been one of the most popular NoSQL databases, while its open-source offshoot Valkey has seen rapid adoption since its launch. Valkey/Redis are often used to implement non-relational key-value databases, caches, and message brokers. Since they keep all data in memory, Valkey and Redis deliver high throughput with very low latency — ideal for many real-time applications.

Although they are often described as key-value stores, it's more accurate to say Valkey and Redis are data structure stores. This is because keys can map not only to strings but to more advanced structures such as lists, sets, hashes, and sorted sets. Valkey or Redis can also be deployed as a distributed database, with Cluster and Sentinel options. For Java developers, the easiest way to leverage all these features is through a client like Redisson.

Redisson is an advanced Java client that maps all Valkey/Redis features to familiar Java objects and collections, such as Map, List, Set, locks, and semaphores. This allows developers to take advantage of a fast, NoSQL key-value store through standard Java interfaces, rather than writing code with low-level commands. To get started, learn more about the features of Redisson and Redisson PRO.