fbpx
wave-1 wave-2

Relationship without relation – non-relational databases (NoSQL). Part 2 – individual types of non-relative databases.

Relationship without relation – non-relational databases (NoSQL). Part 2 – individual types of non-relative databases.
Autor: Artur Pasik

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.

Klucz ? wartość

Advantages and disadvantages:

AdvantagesDisadvantages
Simplicity of the data modelNot very well suited to complex data
High scalabilityNo support for handling data links
High resistance to errors

 

Example: Riak

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):

Przykładowe dokumenty (odpowiedniki wierszy w bazie relacyjnej)

Advantages and disadvantages:

AdvantagesDisadvantages
Simplicity of the data modelLow quality handling of interrelated data
High scalabilityPoorly developed questioning model (keys, indexes)
Large modeling possibilitiesMapReduce

 

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:

Bazy grafowe

Both knots and edges have their properties. The organization of nodes according to relationships allows to find the desired patterns.

Advantages and disadvantages:

AdvantagesDisadvantages
An extensive general data modelData sharding
Simple questioningA 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:

AdvantagesDisadvantages
Support for semi-structural dataNo support for handling data links
Natural indexingSlow line operations (especially those involving more than one line)
High scalability

 

Example: Cassandra

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

  1. P. J. Sadalage, M. Fowler, ?NoSQL Kompendium wiedzy?, Helion 2015
  2. A. Wójcik, ?Nierelacyjne bazy danych?, Zeszyty Naukowe WSEI 2014
  3. https://www.geeksforgeeks.org/introduction-to-nosql/
  4. https://itwiz.pl/czym-jest-nosql-jak-wykorzystac-nierelacyjne-bazy-danych/
  5. https://riak.com/
  6. https://www.mongodb.com/
  7. https://neo4j.com/
  8. http://cassandra.apache.org/

Author: Artur Pasik, Performance/Automation Test Engineer