While relational databases
structure data in a tabular format, non-relational databases do not have such a rigid database schema. In fact, non-relational databases organize data differently depending on the type of database. Regardless of the type of non-relational database, they all aim to solve the flexibility and scalability problems inherent in relational models that are not ideal for unstructured data formats, such as text, video, and images. These types of databases
include: Key-value store
- : This schemaless data model is organized into a dictionary of key-value pairs, where each element has a key and a value. The key could be like something similar found in a SQL database, such as a shopping cart ID, while the value is an array of data, such as each individual item in that user’s shopping cart. It is commonly used to cache and store user session information, such as shopping carts. However, it is not ideal when you need to extract multiple records at once. Redis and Memcached are examples of open source databases with this data model.
- : As the name suggests, document databases store data as documents. They can be useful for managing semi-structured data, and the data is usually stored in JSON, XML, or BSON formats. This keeps data together when used in applications, reducing the amount of translation needed to use the data. Developers also gain more flexibility, as data schemas do not need to match between documents (e.g. name vs. first_name). However, this can be problematic for complex transactions, leading to data corruption. Popular use cases for document databases include content management systems and user profiles. An example of a document-oriented database is MongoDB, the database component of the MEAN stack.
Wide column store
- : These databases store information in columns, allowing users to access only the specific columns they need without allocating additional memory to irrelevant data. This database attempts to address the shortcomings of key-value stores and documents, but because it can be a more complex system to manage, it is not recommended for newer teams and projects. Apache HBase and Apache Cassandra are examples of wide-column open source databases. Apache HBase is based on the Hadoop Distributed Files System that provides a way to store sparse data sets, which is commonly used in many big data applications. Apache Cassandra, on the other hand, has been designed to manage large amounts of data across multiple servers and clusters spanning multiple data centers. It has been used for a variety of use cases, such as social media websites and real-time data analytics.
- Graph store: This type of database typically holds data from a knowledge graph. Data elements are stored as nodes, borders, and properties. Any object, place, or person can be a node. An edge defines the relationship between the nodes. Graph databases are used to store and manage a network of connections between elements within the graph. Neo4j (link resides outside IBM), a Java-based graphics-based database service with an open-source community edition where users can purchase licenses for online backups and high-availability extensions, or prepackaged licensed version with backup and extensions included.
NoSQL databases also prioritize availability over consistency.
When computers run on a network, they invariably need to decide to prioritize consistent outcomes (where each response is always the same) or high uptime, called “availability.” This is called the “CAP Theory”, which stands for Partition Consistency, Availability or Tolerance. Relational databases ensure that information is always synchronized and consistent. Some NoSQL databases, such as Redis, prefer to always provide an answer. That means the information you receive from a query may be incorrect for a few seconds, maybe up to half a minute. On social media sites, this means seeing an old profile picture when the newer one has only a few moments. The alternative could be a timeout or an error. On the other hand, in banking and financial transactions, an error and forwarding can be better than old, incorrect information.
For a full summary of the differences between SQL and NoSQL, see “SQL Databases vs. NoSQL: What’s the Difference?”