NoSQL Databases
NoSQL databases provide an alternative data model to the relational database model. Here's an overview.
Most of this database tutorial has focused on relational database management systems. Although currently the most popular type of database, relational is not the only model available.
There's a new breed of database management system that is often referred to as a "NoSQL database". This type of database doesn't use the relational model — it uses a completely different model altogether.
The actual data model that it uses depends on the database. NoSQL is a very broad term that doesn't refer to one particular database model. Rather, it refers to a whole variety of different models that don't fit into the relational model.
Although NoSQL databases have been around since the 1960s, it wasn't until the early 2000s that the NoSQL approach started to pick up steam, and a whole new generation of NoSQL systems was born.
NoSQL Types
NoSQL databases are usually categorized under one (or more) of following types.
-
Graph
Graph databases use a graphical model to store and represent the data.
Graph databases typically store and display data as nodes and relationships. Nodes are displayed as small circles, relationships are displayed as arrows linking the circles.
Graph databases are very well suited to applications like social networks, realtime product recommendations, network diagrams, fraud detection, access management, and more.
See the Neo4j tutorial for an example of a graph database management system.
-
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.
A simple phone directory is a classic example of a key-value database:
Key Value Homer (123) 456-7890 Jay (234) 567-8901 Grace (345) 678-9012 Bart (456) 789-0123 -
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.
The documents in document stores are usually XML or JSON, but some DBMSs use other languages, such as BSON, YAML, etc.
A JSON document looks like this:
{ '_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' } ] }
See the MongoDB tutorial for an example of a document store database management system.
-
Column Store
A column store database works in a similar fashion to a relational database in that it has 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.
This example shows a column-family (think of it as a table) called UserProfile. This column-family has rows with varying numbers of columns, with varying column names.