Beruflich Dokumente
Kultur Dokumente
4/2015 3
In the context of today’s business needs we must focus on the NoSQL databases because they
are the only alternative to the RDBMS that can resolve the modern problems related to
storing different data structures, processing continue flows of data and fault tolerance. The
object of the paper is to explain the NoSQL databases, the needs behind their appearance, the
different types of NoSQL databases that current exist and to focus on two key-value
databases, Riak and Redis.
Keywords: NoSQL Databases, Key-Value, Riak, Redis, RDBMS
“Wide Column” model pictured in Fig. column family [3]. This model is best to be
4., also known as “Column-Family” or used for distributed data storage, large-scale,
“Big Table implementation” has a batch-oriented data processing like sorting,
database structure that is similar to the parsing, conversions between hexadecimal,
standard RDBMS because all the data is binary and decimal code and predictive
stored under sets of columns and rows. analytics [2].
One important functionality is the Example of wide column databases:
grouping of the often used columns in Cassandra, HBase, BigTable(Google)
PUT
http://localhost:8091/riak/cars/
bmw Header: "Content-Type:
application/json"
Body: '{"model" : "520", "year"
: "2014"}'
Response:
Fig. 5. Graph model [8] HTTP/1.1 200 OK
POST
3 Riak Database
http://localhost:8091/riak/cars
Riak represents a distributed key-value Header: "Content-Type:
database that can store any type of values, application/json"
from plain text, JSON, XML to images or Body: '{"model" : "A4", "year" :
video clips that can be accessible by a "2010"}'
simple HTTP interface. Riak supplies an
HTTP REST interface where you are able Response:
to query via URLs, headers, and verbs HTTP/1.1 201 Created
and receive standard HTTP response Location: /riak/cars/
9cBK3o9zlXq7B45kJrm1S0Ma3PO
codes. REST comes from Representation
State Transfer and it is used to map
resources to URLs and interact with them To retrieve the value of a resource you can
using the CRUD set of verbs: Create simply send a GET request to the specific
(POST), Read (GET), Update (PUT) and location. Example: GET
http://localhost:8091/riak/cars/
Delete (DELETE).
bmw
Database Systems Journal vol. VI, no. 4/2015 7
To remove a key/value pair, simply send replication of data on a number of its nodes,
a DELETE request to the specific controlled by a value called the N-Value. By
location and you will receive a HTTP 204 default for Riak the value of N is 3 for all
response code in case of success or a the nodes, which means that Riak will
HTTP 404 in the case of error. replicate all the information for three times,
Example:DELETE but with Riak this value can be overridden
http://localhost:8091/riak/car on each bucket. Riak databases are designed
s/bmw to be used as distributed systems and by
adding nodes to the cluster, the data read
Riak databases introduce the “Links” and write, as well as the execution of the
concept in order to support relations map/reduce queries will be faster [10].
between keys. A “Link” is a metadata
that associates multiple keys and it 4 Redis database
consist of two parts: the key where the Redis database if part of the Key-Value
value links to, and a string tag describing NoSQL database group that supports data
how the link relates to this value. structures more advanced than the Riak
(Link: </riak/bucket/key>; database, but less than a document-oriented
riaktag="contains") database and it supports a set-based query
operations.
PUT
http://localhost:8091/riak/d
It is one of the fastest NoSQL databases
ealer/bmwShop trading durability over speed. Redis can be
considered more a toolkit of useful data
Header: structure algorithms than an ordinary
"Content-Type: member of a database group because it
application/json" contains a list of processes and
”Link: </riak/cars/bmw>; functionalities like a blocking queue or
riaktag="contains")” stack, a publisher-subscriber system and a
list of configurable features as expiry
Body: '{"cars" : "20",
policies, durability levels and replication
"address" : "Bucharest,
Street Paris, Number 10"}' options [1].
In Redis, the operations to create and update
MapReduce is an algorithm and a data are made using the SET and MSET
programming model to process and keywords. The syntax follows this patterns:
generate large data sets. The associated SET <key> <value> or MSET <key1>
implementation breaks the problem into <value1> <key2> <value2>. MSET
two parts. The first part is to specify a keyword is used to specify a multiple set
map() function that can process a operation provided by Redis for reducing the
key/value pair to generate a set of traffic. In the case of successful adding or
intermediate key/value pairs and the updating the data, the Redis server will
second part is a reduce() function that respond with an “OK” message. Example:
converts the second list of intermediate “SET bmw 320i” vs “MSET bmw 320i
key/value pairs into one or more scalar audi A4”
values [9]. Following this pattern, Riak For data retrieval we have the counterpart
allows a system to divide tasks into keywords GET and MGET using the
smaller components and run them across following syntax: “GET <key>” vs “MGET
a massive cluster of servers in parallel. <key1> <key2>”
When it comes to availability and Redis can store not only string text values
scalability, Riak exceeds some of the but also numeric ones and will recognize
RDBMS such as MySQL and document integers and will provide some simple
databases like CouchDB, maintaining operations for them, like INCR/INCRBY
8 NoSQL Key-Value DBs Riak and Redis
(increment / increment by) and any number of key/value pairs and help to
DECR/DECRBY (decrement /decrement avoid storing data with artificial key
by). prefixes. In the case of hashes, all the
In comparison to Riak, the previous key- commands are prefixed by the H character.
value database type presented, Redis add To create a hash that contains key/value
the transaction concept using the MULTI pairs, run the HMSET command as it
block atomic commands that offer the follows: HMSET <hash> <key1>
possibility to execute multiple operations <value1> <key2> <value2>.<keyN>
like SET or INCR in a single block that <valueN>. To retrieve all values from a
will complete either successfully or not at hash, run: HVALS <hash> and to check all
all. Different from the traditional the keys, run HKEYS <hash>. To get a
transaction concept from RDBMS, in single value, run: HGET <hash> <key>.
Redis when it is decided to stop a Lists contain multiple ordered values that
transaction with the DISCARD command can be stored and retrieved like FIFO (First
there will be no rollback triggered and no in, First out) in the case of queues or like
reverts in the database because the LIFO (Last in, First out) in the case of stack.
commands will not have been executed. It also has specific insert operations, for
The effects are the same, even though example insert on the right (end) of a list
there is a different mechanism (RPUSH), insert on the left (begin) of a list
(transaction rollback vs operation or insert in the middle of a list. Sets are
cancellation). represented by unordered collections that do
Redis popularity does not rise from not have duplicated values and are an
running operations with simple types like excellent choice for running complex
text strings or integers, but from operations between more key values, as
processing operations with complex data unions or intersections [1].
types as lists, hashes, sets and sorted sets
over a huge number of values up to 232 5 Comparison between Riak and Redis
elements per each key. Hashes can take databases
REST
Erlang
Data types Binary/Data Data structures
structures/JSON
MapReduce Yes No
ACID properties CID (Consistency, ACID(Atomicity, Consistency, Isolation
Isolation and and Durability)
Durability)
Transactions No Yes
Server operating Linux, OS X, BSD, Linux, OS X, Windows
systems
Has hashes, sets and No Yes
lists
Buckets Yes No
Best for High availability, For rapidly changing data, Frequently
Partition tolerance, written, rarely read statistical data
Persistence
New Era of Databases for Big data Intelligence and Big Data, [Read:
Analytics - Classification, 16 April 2016.], https://bi-
Characteristics and Comparison, bigdata.com/2013/01/14/what-is-
International Journal of Database graph-databases/
Theory and Application Vol. 6, [9] Jeffrey Dean, Sanjay Ghemawat,
No. 4. 2013. “MapReduce: Simplified Data
[3] Veronika Abramova , Jorge Processing on Large Clusters”,
Bernardino, Pedro Furtado, Google Research Publications,
Experimental Evaluation Of http://research.google.com/archive
NoSQL Databases, International /mapreduce.html
Journal of Database Management [10] Yousaf Muhammad, “Evaluation
Systems ( IJDMS ) Vol.6, No.3, and Implementation of Distributed
June 2014 NoSQL Database for MMO
[4] A SHORT HISTORY OF Gaming Environment”, October
DATABASES: FROM RDBMS 2011, Department of Information
TO NOSQL & BEYOND. Technology, http://www.diva-
www.3pillarglobal.com.[Read: 16 portal.org/smash/get/diva2:447210
April 2016.] /FULLTEXT01.pdf
http://www.3pillarglobal.com/insig [11] “Not So Versus, Riak Versus
hts/short-history-databases-rdbms- Redis”,
nosql-beyond. https://compositecode.com/,
[5] NOSQL DATABASES. [Read: 16 April 2016.],
www.sqrrl.com.[Read: 15 April https://compositecode.com/2013/0
2016.] 2/10/riak-redis/
https://sqrrl.com/product/nosql/ [12] Riak vs Redis, http://vschart.com/
[6] Mahdi Atawneh, “01 NoSql and [Read: 16 April 2016.],
multi model database”, http://vschart.com/compare/riak/vs
http://www.slideshare.net/MahdiAt /redis-database
awneh. [Read: 15 April 2016.] [13] Ahmed Oussous , Fatima-Zahra
http://www.slideshare.net/MahdiA Benjelloun , Ayoub Ait Lahcen ,
tawneh/01-nosql-and-multi-model- Samir Belfkih, Comparison and
database Classification of NoSQL
[7] Sandip Shinde, “What is Wide Databases for Big Data., [Read:
Column Stores?”, SQL Server 16 April 2016.],
Business Intelligence and Big https://www.researchgate.net/profi
Data, [Read: 16 April 2016.], le/Ayoub_Ait_Lahcen/publication/
https://bi- 278963532_Comparison_and_Clas
bigdata.com/2013/01/13/what-is- sication_of_NoSQL_Databases_fo
wide-column-stores/ r_Big_Data/links/55880d3408ae65
[8] Sandip Shinde,” What is Graph ae5a4dfa26.pdf
Databases?”, SQL Server Business