NoSQL databases are often categorised under four main types. Some databases are a mix between different types, but in general, they fit under the following main categories.
Key-Value
A key-value database, is a database that uses a simple key/value method to store data.
The key-value part refers to the fact that the database stores data as a collection of key/value pairs. This is a simple method of storing data, and it is known to scale well.
Here’s an example of a key-value store:
Key | Value |
---|---|
Bob | (123) 456-7890 |
Jane | (234) 567-8901 |
Tara | (345) 678-9012 |
Tiara | (456) 789-0123 |
This is a simple phone directory. The person’s name is the key, and the phone number is the value.
This type of database is very quick to query, due to its simplicity.
The key-value model is well suited to storing things like user profiles and session info on a website, blog comments, telecom directories, IP forwarding tables, shopping cart contents on e-commerce sites, and more.
Examples of key-store database management systems include:
Document Store
A document store database uses a document-oriented model to store data. It is similar to a key-value database in that it uses a key-value approach. The difference is that, the value in a document store database consists of semi-structured data.
Also known as a document oriented or aggregate database, a document store database stores each record and its associated data within a single document. Each document contains semi-structured data that can be queried against using various query and analytics tools of the DBMS.
The documents in document stores are usually XML or JSON, but some DBMSs use other languages, such as BSON, YAML, etc.
Here’s an example of a document written in JSON:
{ '_id' : 1, 'artistName' : { 'Iron Maiden' }, 'albums' : [ { 'albumname' : 'The Book of Souls', 'datereleased' : 2015, 'genre' : 'Hard Rock' }, { 'albumname' : 'Killers', 'datereleased' : 1981, 'genre' : 'Hard Rock' }, { 'albumname' : 'Powerslave', 'datereleased' : 1984, 'genre' : 'Hard Rock' }, { 'albumname' : 'Somewhere in Time', 'datereleased' : 1986, 'genre' : 'Hard Rock' } ] }
In a document store, this document can be retrieved by referring to the _id
.
Document store databases can be used for a wide variety of use cases. They are ideal for content management systems, blogging platforms, and other web applications.
They are also well suited for user generated content such as blog comments, chat sessions, tweets, ratings, etc.
Document stores are also great for providing real time analytics and other reporting features.
Here are examples of document store DBMSs.
Column Store
A column store database is a type of database that stores data using a column oriented model.
Column stores work in a similar fashion to relational databases in that they have rows, columns, and tables (also known as column families). However, these work differently in column store databases.
In a column store database, the columns in each row are contained within that row. Each row can have different columns to the other rows. They can be in a different order, then can even have different data types, etc.
Here’s a diagram to demonstrate this:
This method of storing data can be extremely quick to load and query.
Columnar databases can also store massive amounts of data, and they can be scaled easily using massively parallel processing (MPP), which involves having data spread across a large cluster of machines.
Examples of column store databases include:
Graph
Graph databases use a graphical model to represent and store the data.
Here’s a basic example of how graph databases store and present data:
The circles are nodes – they contain the data. The arrows represent the relationships that each node has with other nodes.
Graph databases are an excellent choice for working with connected data – data that contains lots of interconnected relationships. In fact, graph databases are much more suited to displaying relational data than relational databases.
Graph databases are very well suited to applications like social networks, realtime product recommendations, network diagrams, fraud detection, access management, and more.
As with most NoSQL databases, there’s no fixed schema as such. Any “schema” is simply a reflection of the data that has been entered. As more varied data is entered, the schema grows accordingly.
Examples of graph databases include Neo4j, Blazegraph, and OrientDB.
Also check out this list of over 40 graph database management systems.
Multi Model
Some databases include features/characteristics of more than one data model. These databases are usually categorised under one or both of the models they use. They can also be referred to as multi model databases.
Some examples of multi model databases include: