Last Updated:

What is NoSQL?

For decades, database professionals have depended on a single standard supported by all databases, the Structured Query Language (SQL). We relied on a tabularly oriented relational database and used it to store and access data. No one thought about alternativama. However, times have changed. The NoSQL (Not only SQL) model rejects many well-established notions of the "correct" database structure. But NoSQL offers the opportunity to get increased productivity.

Changes in the model. The Emergence of NoSQL

Relational databases have always been based on immutable structured rules governing transactions. These rules make up the ACID model, which requires the database to store atomicity, consistency, isolation, and longevity of transactions. Any action that may violate the ACID model is prohibited.

NoSQL turns the ACID model on its head and allows a laissez-faire approach to database management: the BASE model. Instead of being rigidly bound to ACID principles, BASE offers three loose directives: basic availability, unstable state, and ultimate consistency. It is fair to say that the BASE principle is a relaxed alternative to the strict ACID model that relational databases use.

If not tables, then what?

Instead of structured tables with many attributes, NoSQL uses the principle of "key / value".This is quite simple, there is no database structure. NoSQL simply stores the value for each key presented, distributes it to the database, and allows you to return the value efficiently. The lack of structure protects against complex queries and actually prevents the use of NoSQL as a transactional environment.

There are four types of NoSQL databases:

  • The key/value database is nothing more than the function described above — the data binary associated with its key is stored in the database for later retrieval.
  • A document-oriented database goes a bit beyond the previous principles. It imposes a specific structure on a binary object. Objects must be documents of recognizable format, XML or PDF. However, there are no requirements for the structure or content of the document. Each document is stored as a value (in a key/value structure) and can be accompanied by metadata embedded in itself.
  • Column-like databases are a hybrid of NoSQL and relational databases. It assumes a certain row-column structure, but does not have rigid rules of relational structure.
  • A graph-based database stores data in tuples with many attributes that reflect the relationship in a different way. For example, "friendly" social media connections can be stored as a record that includes just two users who are friends.

NoSQL Architecture

The basis of a database in NoSQL is a hash function, a mathematical algorithm that turns input of any size into fixed-length output. The key of each key/value pair is created using hashing, and this hash code is used to direct the pair to a NoSQL server where it will be stored for future searches.

To find the key/value pair, you need to provide the database with the key itself.

After reading the description of this process, the question may arise: "How does a user or program perform complex queries, such as searching for keys that have a specific value, or sorting by value?" The answer is simple – NoSQL simply does not support functionality of this type. NoSQL is designed to efficiently store key/value pairs with quick access to them when the program just needs a place to store the data and then search for it only by the key.

If you need to run other queries, then NoSQL is not the right platform for you.

Redundancy and Scalability in NoSQL

The simplified architecture of NoSQL databases is a major advantage when it comes to redundancy and scalability. To create positive redundancy, the administrator simply creates a duplicate node and configures copying between the primary node and the duplicate. Scalability is simply a matter of additional nodes. When they are added, NoSQL modifies the hash function to assign new entries to new nodes in a balanced manner.

Inference

We do not want to say that NoSQL databases will capture the market at lightning speed. Moreover, given their limitations, they will never completely replace relational databases. However, they have a promising future for simple data storage in a highly efficient way. So don't be surprised when you notice an increase in their use.