In relational databases it is difficult to store and process poorly structured or unstructured data. To solve these problems, there is a separate type of databases – non-relational databases.
Key-value databases
Data is stored as a table with keys and specific values. Key-value databases are often used in conjunction with other databases as a caching mechanism.
Advantages:
Suitable for different data (files, text, numbers) under different keys;
fast access to data due to address-based storage;
sharding rules for specific keys.
Disadvantages:
no standard database features: transaction atomicity, data consistency when multiple transactions are executed simultaneously;
hard to maintain unique keys as data volumes increase.
Examples: Amazon DynamoDB, Redis, Riak, LevelDB, Memcached, etc.
Document-oriented databases
Data is stored as JSON documents. They are grouped into collections that form database systems. The content of a document can have a different set of properties and characteristics. Therefore, such databases are used to create catalogs, books, blogs, and video streaming platforms.
Advantages:
Suitable for developing services that work with differently structured data;
easy to scale and change structure;
fast document creation and minimal maintenance;
no foreign keys, so all documents are independent of each other;
uses XML, JSON and others to describe documents.
Disadvantages:
Consistency checking limitations that degrade database performance;
difficulties in retrieving data from multiple related sources;
risks of sensitive web application data leakage.
Examples: MongoDB, RethinkDB, CouchDB, DocumentDB.
Graph
Graph databases model relationships between complexly interconnected objects. They are based on topographic network structure and mathematical graph theory. Graphs represent data sets in the form of nodes, edges and properties. Such databases help to provide real-time recommendations to resource users and improve user experience. For example, music services offer customized track selections and marketplaces offer lists of products based on favorites.
Advantages:
High performance and adaptive structure;
clear relationships between entities;
real-time results.
Disadvantages:
No standardized query language;
graphs are not suitable for transaction-based systems.
Examples: Neo4J, JanusGraph, Dgraph, OrientDB.
Columnar
Columnar databases store data in columns rather than tables. Keys indicate the format of the row of a record of information about an object. Each row has its own set of properties, so differently structured data can be stored within the same family. Columnar databases are used for analyzing large amounts of data. For example, for filtering and sorting products in an online store or for obtaining statistics from the site in terms of days, categories, prices, and so on.
Advantages:
Ability to make complex selections on large tables;
instant change of the structure of large tables;
execution of fast queries;
easy scalability and modifiability of the structure.
Disadvantages:
Slow write performance;
does not support transactions;
limitations for developers.
Examples: Cassandra, HBase, ClickHouse.
Time series databases
Time series is anything that can be measured in terms of time periods: hour, day, month or year, etc. Metrics can be various data: traffic changes on roads, water level in a river, server load and others. Data can be queried, plotted, analyzed and dependency between different metrics can be found. Database performance depends on different factors: amount of information, number of queries and metrics.
Examples: OpenTSDB, Prometheus, InfluxDB, TimescaleDB.