Relationship without relation – non-relational databases (NoSQL). Part 2 – individual types of non-relative databases.
As already described in Part 1 (available at: PART 1), non-relative databases can be divided into several categories (in terms of data model):
- The key ? value
- The document
- The graph
- The family of columns
The following article provides a brief description of each of them. For a more complete picture of individual types of non-relative databases, a sample data model, implementation and characteristic advantages and disadvantages are also added.
Key – value
The data model is in the form of a large scalable HashMap. Each single element in the database is stored as an attribute name (“key”) together with its value.
With the key, the customer has the possibility to obtain a given value, insert a new value into it, or delete it completely.
A value, on the other hand, is a “blob” field, which is simply stored, without specifying a particular type of data (as in the illustration below). The understanding of the content lies with the application.
Advantages and disadvantages:
Advantages | Disadvantages |
---|---|
Simplicity of the data model | Not very well suited to complex data |
High scalability | No support for handling data links |
High resistance to errors |
Example: Riak
A new data warehouse with high availability, ease of use and scalability. In addition to the open source version, it is available in a supported corporate and cloud storage version. The rakia has a fail – safe data replication and automatic data distribution in the cluster to ensure performance and resilience.
Default interaction with the database via HTTP API:
- GET ? reading
- PUT ? updating, inserting (when entering the key)
- DELETE ? removal
- POST ? inserting (key generation on the database side)
Other examples: Aerospike, Apache Ignite, ArangoDB, BerkeleyDB, Couchbase, Dynamo, FairCom c- treeACE, FoundationDB, InfinityDB, LevelDB, MemcacheDB, MUMPS, Oracle NoSQL Database, OrientDB, Project Voldemort, Redis, Berkeley DB, SDBM/Flat File dbm, ZooKeeper
Documents
As the name suggests, their main element is documents. These are self-describing, hierarchical tree structures, stored and returned by the database. Sample formats of documents:
- XML
- JSON
- BSON
Documentary databases are a collection of documents, which in turn constitute a key-value warehouse. The stored documents are usually comparable, but do not necessarily have to be the same.
Sample documents (equivalents of lines in the relational database):
Advantages and disadvantages:
Advantages | Disadvantages |
---|---|
Simplicity of the data model | Low quality handling of interrelated data |
High scalability | Poorly developed questioning model (keys, indexes) |
Large modeling possibilities | MapReduce |
Example: MongoDB
Multi-platform, non-relational database system, created in C++ language. It does not have a strictly defined structure of supported databases, instead it uses documents in BSON format (slightly similar to JSON, but in binary form). This allows applications to process them more naturally, while maintaining the ability to create hierarchies and indexing.
Other examples: Apache CouchDB, ArangoDB, BaseX, Clusterpoint, Couchbase, Cosmos DB, IBM Domino, MarkLogic, OrientDB, Qizx, RethinkDB
Graphical
Graphic databases are based on storing knots and edges between them. A node is equivalent to an entity, while the edges correspond to a relationship. An example model can be presented as follows:
Both knots and edges have their properties. The organization of nodes according to relationships allows to find the desired patterns.
Advantages and disadvantages:
Advantages | Disadvantages |
---|---|
An extensive general data model | Data sharding |
Simple questioning | A complete change in thinking |
Example: Neo4J
ACID-compliant transactional database with native graph storage and processing. One of the most popular solutions in the category of graphical databases.
Neo4j has been implemented in Java but is also available from applications written in other languages. This is made possible by a dedicated query language called Cypher, communicating via HTTP transactional endpoint or ?bolt? binary protocol.
Other examples: AllegroGraph, ArangoDB, InfiniteGraph, Apache Giraph, MarkLogic, OrientDB, Virtuoso
Columnal (Column families)
In the case of column family databases, as the name suggests, the data is stored in the form of a column family – a group of related data that is usually collected together. These, in turn, are stored in rows with assigned keys.
The concept of this type of database can be compared to a huge, demoralized table with many rows and columns. Therefore, they are mainly used in the VLDB (Very Large DataBase) sector.
Advantages and disadvantages:
Advantages | Disadvantages |
---|---|
Support for semi-structural data | No support for handling data links |
Natural indexing | Slow line operations (especially those involving more than one line) |
High scalability |
Example: Cassandra
A distributed database management system designed to handle large numbers of distributed data on multiple servers. Write operations are performed on the whole cluster that does not have a main server. This enables asynchronous reading and writing of data, which translates into minimized delays.
Cassandra has a query language called CQL (Cassandra Query Language). It supports commands similar to SQL statements.
Other examples: Amazon SimpleDB, Accumulo, Druid, HBase, Hypertable, Vertica
Summary
There is no one comprehensive data model to remedy all illnesses. Each of them presents its own specific properties and is used in the area where they work best.
The choice of a specific solution should be dictated by the desired features of the database and the problems they are supposed to prevent.
The above article gives an opportunity to get acquainted with individual data models and their specific implementations, which shed some light on the subject and gives a general picture of the most popular solutions on the market today.
Sources
- P. J. Sadalage, M. Fowler, ?NoSQL Kompendium wiedzy?, Helion 2015
- A. Wójcik, ?Nierelacyjne bazy danych?, Zeszyty Naukowe WSEI 2014
- https://www.geeksforgeeks.org/introduction-to-nosql/
- https://itwiz.pl/czym-jest-nosql-jak-wykorzystac-nierelacyjne-bazy-danych/
- https://riak.com/
- https://www.mongodb.com/
- https://neo4j.com/
- http://cassandra.apache.org/