An overview of NoSQL databases and their comparison with SQL syntax

The NoSQL database was created to solve the challenges brought by large-scale data collections and multiple data types, especially the problems of big data applications.

This article briefly introduces the definition, classification, characteristics, and popular NoSQL database systems of NoSQL databases, and makes a simple comparison of NoSQL and SQL syntax, providing a useful reference for everyone to learn about NoSQL databases.

First, the emergence of NoSQL

Relational database systems have achieved great success in solving data storage, service and processing problems over the years. Some large companies have built their own systems using relational databases, such as online transaction processing systems and back-end analytical applications. Online Transaction Processing (OLTP) systems are used to record transaction information in real time. The expectation for such systems is to be able to return response information quickly (usually in the millisecond range). Online Analytical Processing (OLAP) systems are used to analyze and query the stored data. OLAP falls under the category of business intelligence, where data needs to be studied, processed and analyzed in order to gather information that further drives business decisions.

The internal design of relational databases is determined by relational algorithms, and these systems require a pre-defined schema and type of data to conform to. SQL is the standard way of interacting with these systems. But in situations where object-relationship mismatches arise, SQL is not the best way to express access patterns. For example, in the current hot field of big data, relational databases do not work well.

Common definitions of big data include: first, big data means data that is big enough that you have to study it in order to gain some insights from it; second, big data is data that is no longer applicable to a single machine. These views are not complete, and we need to think about data in a fundamentally different way, in terms of how it drives business value, and that data is big data.

In the field of big data, the system needs to be able to adapt to different kinds of data formats and data sources, not need to strictly define the schema in advance, and be able to handle large-scale data. In this way, NoSQL came into being.

Second, the definition of NoSQL

NoSQL (NoSQL= Not Only SQL ), which means "more than just SQL", is a brand-new database revolutionary movement. Advocates of NoSQL advocate the use of non-relational data stores. Most database technologies are not guaranteed to support ACID (Atomicity, Consistency, Isolation, and Durability), and most of the technologies are open source projects, and these technologies as a whole are called NoSQL.

3. Classification of NoSQL

Generally NoSQL databases are divided into four categories: key-value storage databases, column storage databases, document databases and graph databases. Their data models, advantages and disadvantages, and typical application scenarios are shown in Table 1.

Table 1 Analysis of the

four Characteristics of

NoSQL NoSQL databases do not have a unified architecture, but they all have some common characteristics shown in Table 2.

Table 2 Features of NoSQL

Feature

Description

No need to pre-defined schema

No need to define data schema in advance, pre-defined table structure and so on. Each record in the data may have different attributes and formats

. The shared-nothing architecture

of NoSQL often divides the data and stores it on each local server, thereby improving the performance of the system.

Elasticity and scalability

It is possible to dynamically add or delete records while the system is running. point. Data can be automatically migrated without downtime for maintenance.

Partitioned

NoSQL databases partition data, scatter records on multiple nodes, and usually do replication at the same time as partitioning.

Asynchronous replication Replication

in NoSQL is often log-based asynchronous replication. In this way, data can be written to a node as quickly as possible without network transmission delay

BASE

Compared with the ACID feature, the NoSQL database guarantees the BASE feature (BASE is eventual consistency and soft transactions).

Fifth, common NoSQL databases are

more suitable for the use of NoSQL databases: (1) The data model is relatively simple; (2) It needs to be flexible (3) It has higher requirements on database performance; (4) It does not require high data consistency; (5) For a given key, it is easier to map complex values ​​to the environment.

Common NoSQL databases are shown in Table 3.

Table 3 Common NoSQL databases

Category Example

Key-Value storage database * Riak: An open source, distributed key-value database that supports data replication and fault tolerance * Redis: An open-source key-value storage database that supports master-slave replication , transaction, Pub/Sub, Lua script, also supports adding time limit to Key * Dynamo: a key-value distributed storage database, directly implemented by Amazon Dynamo database * Oracle NoSQL Database: key-value NoSQL database from Oracle, supports transaction ACID and json * Oracle NoSQL Database: with data backup and distributed key-value storage system * Voldemort: with data backup and distributed key-value storage system * Aerospike: a key-value storage database, supporting hybrid memory architecture, through strong consistency and tunable Consistency ensures data integrity Column store database



















* Cassandra: supports data replication across data centers and provides column indexes

* Hbase : an open source, distributed, column-oriented storage model

* Amazon SimpleDB: a non-relational data store

* Apache Accumulo: ordered, distributed key-value Data storage, based on Google's BigTable design

* Hypertable: An open source, scalable database that mimics Bigtable and supports sharding

* Azure Tables: Provides NoSQL performance for applications requiring large amounts of unstructured data storage

Document database

* Mongodb : Open source, Document-oriented

*CounchDB: A document database using JSON, using Javascript for MapReduce queries, and an API using HTTP

*Couchbase: based on JSON models

*RavenDB: a document-oriented database based on .net language

*MarkLogic: used to store XML based and document-centric information, supporting flexible

schemas Graph database

* Neo4j: a graph database that supports ACID transactions

* InfiniteGraph: used to maintain and traverse relationships between objects, support distributed data storage

* AllegroGraph: used in combination It provides high scalability and supports SPARQ, RDFS++ and Prolog reasoning.

6. Simple comparison of NoSQL and SQL syntax

The basic situation of NoSQL has been introduced above. The following takes HBase and ORACLE as examples to briefly compare the syntax of NoSQL and SQL. The HBase database is considered one of the most secure NoSQL database products, and it has proven to be a powerful tool, especially where Hadoop is already in use. Today, it is an Apache top-level project with a large developer and thriving user community.

1. Create a table

If you want to create a table "mytable", which contains an "info" field, then:

(1) The syntax in ORACLE is:

create table mytable

(

info varchar(30) not null

);

(2) HBase The syntax in is:

create 'mytable', 'cf'

This command creates a table 'mytable' with one column family ("cf").

2. Write data

If you want to write data "hello hbase" to the table, then:

(1) The syntax in ORACLE is:

insert into mytable(info) values('hello hbase');

(2) The syntax in HBase is :

put 'mytable', 'first', 'cf:info', 'hello hbase'

This command inserts "hello hbase" into the data cell corresponding to the "cf:info" column in the "first" row of the "mytable" table .

3.

If you want to read a single piece of data from the table, then:

(1) The syntax in ORACLE is:

select * from mytable where info = 'hello hbase';

(2) The syntax in HBase is:

get 'mytable', 'first'

The command outputs the data unit for that row.

If you want to read all the data from the table, then:

(1) The syntax in ORACLE is:

select * from mytable;

(2) The syntax in HBase is:

scan 'mytable'

This command outputs all the data.

4. Delete data

If you want to delete data from the table, then:

(1) The syntax in ORACLE is:

delete from mytable where info = 'hello hbase';

(2) The syntax in HBase is:

put 'mytable', 'first ', 'cf:info', 'hello hbase1'

This command overwrites the old value with the latest value, which is equivalent to deleting the original data.

5. Modify the data

If you want to modify the data in the table, then:

(1) The syntax in ORACLE is:

update mytable set info = 'hello hbase1'

(2) The syntax in HBase is:

put 'mytable', 'first', 'cf:info', 'hello hbase1'

This command overwrites the old value with the latest value, which is equivalent to modifying the original data.

6. Delete table

If you want to delete a table, then:

(1) The syntax in ORACLE is:

drop table mytable;

(2) The syntax in HBase is:

disable 'mytable'

drop 'mytable'

This command will first "disable" the table , and then "drop" it.

We can see that the syntax of HBase is relatively simple, so all the above commands can be put into a shell script and the commands can be executed in batches. Next, let's do it in detail: The

first step is to write a script named "command.sh", the content of which is as follows:

exec /root/zhouzx/hbase-1.0.1/bin/hbase shell <<EOF

create 'mytable' , 'cf'

put 'mytable', 'first', 'cf:info', 'hello hbase'

get 'mytable', 'first'

scan 'mytable'

put '





In the second step of EOF

, upload the script to the user who installed HBase on the Linux machine, and execute the "dos2unix command.sh" and "chmod 777command.sh" commands in turn to convert the file format and assign permissions to the file.

The third step is to execute the "./command.sh" command. On the Linux interface, we can see the following output information:

HBase Shell; enter 'help<RETURN>' for list of supportedcommands.

Type "exit<RETURN>" to leave the HBase Shell

Version 1.0.1, r66a93c09df3b12ff7b86c39bc8475c60e15af82d, Fri Apr17 22:14:06 PDT 2015

create 'mytable', 'cf'

0 row(s) in 0.6660 seconds Hbase

::Table - mytable

put 'mytable', 'first' , 'cf:info', 'hello hbase'

0 row(s) in 0.1140 seconds

get 'mytable', 'first'

COLUMN CELL

cf:info timestamp=1435807200326,





ROW COLUMN+CELL

first column=cf:info,timestamp=1435807200326, value=hello hbase

1 row(s) in 0.0210 seconds

put 'mytable', 'first', 'cf:info', 'hello hbase1'

0 row(s ) in 0.0040 seconds

disable 'mytable'

0 row(s) in 1.1930 seconds

drop 'mytable'

0 row(s) in 0.1940 seconds

The entire script executes in just a few seconds, but all the HBase commands we mentioned earlier are included , which shows the power of batch processing. Everyone must have a good experience.

7. Summary

This article provides a comprehensive introduction to NoSQL and compares the differences between it and SQL syntax. Although most NoSQL data storage systems have been deployed in practical applications, there are still the following challenging problems to be solved:

First, most of the existing key-value database products are autonomously built for specific applications and lack generality.

Second, the functions supported by existing products are limited (do not support transaction features), resulting in certain limitations in their application.

Third, there have been some research results and improved NoSQL data storage systems, but they are all corresponding solutions for different application requirements, rarely consider the generality of the system from a global perspective, and have not formed a series of research results.

Fourth, it lacks the support of powerful theory (such as armstrong axiom system), technology (such as mature heuristic-based optimization strategy, two-stage blocking protocol, etc.) and standard specification (such as SQL language) that similar relational databases have.

Fifth, many NoSQL databases do not provide built-in security mechanisms.

With the development of cloud computing, mobile Internet and other technologies, big data exists widely, and many new applications in the cloud environment have emerged, such as social networking, mobile services, collaborative editing, etc. These new applications also put forward new requirements for massive data management or cloud data management systems, and NoSQL databases have great opportunities in these areas. We have reason to believe that the tomorrow of NoSQL database will be even better!

Original link: http://www.kubiji.cn/juhe-id5518.html

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326420395&siteId=291194637