A NoSQL database overview and its comparison with SQL syntax

Source: Internet
Author: User
Tags value store

NoSQL databases are created to address the challenges of multiple data types for large data sets, especially for big data applications.

In this paper, the definition, classification, characteristics of NoSQL database, and the current popular NoSQL database system are briefly introduced, and the NoSQL and SQL syntax are compared simply, which provides a useful reference for the study of NoSQL database.

First, the advent of NoSQL

The relational database system has been a great success in solving data storage, service and processing problems for many years. Some large companies use relational databases to build their own systems, such as online transaction processing systems and back-end analysis applications. Online transaction processing (OLTP) systems are used to record transaction information in real time. The expectation for such systems is the ability to quickly return response information (typically in milliseconds). An online analytical processing (OLAP) system is used to analyze the data stored by the query. OLAP is a business intelligence category where data needs to be researched, processed, and analyzed to gather information and drive business decisions further.

The internal design of a relational database is determined by the relational algorithm, which needs to pre-define a schema and the type of data to be followed. SQL is the standard way to interact with these systems. But in the case of object-relationship mismatch problems, SQL is not the best way to express access patterns. For example, in the current hot big data field, relational databases do not work well.

Common definitions for Big data include: First, big data means that the data is big enough that you have to study it to get some insights from that data, and second, big data is no longer applicable to a single machine. These ideas are not complete, and we need to consider the data in a fundamentally different way, from the perspective of how to drive business value, the data is big data.

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

Second, the definition of NoSQL

NoSQL (nosql= not-only sql), meaning "not just SQL," is a new revolutionary movement in the database. NoSQL advocates are advocating the use of non-relational data storage. Most database technologies are not guaranteed to support acid (atomicity, consistency, isolation, and durability), and most of the technologies are open source projects, which are called nosql as a whole.

Iii. categories of NoSQL

NoSQL databases are generally divided into four categories: Key-value (key-value) storage database, Columnstore database, document database, and graph database. Their data models, advantages and disadvantages, and typical application scenarios are shown in table 1.

Table 14 Large NoSQL Database analysis

Iv. Characteristics of NoSQL

NoSQL databases do not have a unified architecture, but they all have common features as shown in table 2.

Table 2 Features of NoSQL

No need to define data schema, predefined table structure, etc. Each record in the data may have different properties and formats

features

Description

No shared schema

NoSQL tends to partition data and store it on individual local servers, improving system performance

can dynamically add or delete nodes while the system is running. No maintenance required, data can be migrated automatically

NoSQL databases partition the data, spread the records across multiple nodes, and usually partition them at the same time.

Asynchronous replication

The replication in NoSQL, often log-based asynchronous replication. This allows the data to be written to a node as soon as possible without delay in network transmission

With respect to acid properties, the NoSQL database guarantees the base attribute (base is final and soft)

V. Common NOSQL databases

The more suitable use of NoSQL database is: (1) The data model is relatively simple, (2) It system needs more flexibility, (3) The database performance requirements are high, (4) There is no need for high data consistency, (5) for a given key, it is easier to map complex values of the environment.

A common NoSQL database is shown in table 3.

Table 3 Common NoSQL databases

Classification

Instance

Key value (key-value) store database

* Riak: An open source, distributed key-value database that supports data replication and fault tolerance

* Redis: An open Source key-value store database that supports master-slave replication, transactions, Pub/sub, LUA scripts, and adds time limits to keys

* Dynamo: A key-value distributed storage database, implemented directly by Amazon Dynamo database

* Oracle NoSQL Database: Key-valued NoSQL databases from Oracle, supporting transaction acid and JSON

* Oracle NoSQL Database: Data backup and distributed key-value storage System

* Voldemort: Data backup and distributed key-value storage System

* Aerospike: A key-value storage database that supports a hybrid memory architecture that ensures data integrity through strong consistency and adjustable consistency

Column Store Database

* Cassandra: Supports data replication across data centers, providing column indexes

* HBase: An open-source, distributed, columnstore-oriented 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, extensible database that mimics bigtable and supports sharding

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

Document Type Database

* MongoDB: Open source, document-oriented

* COUNCHDB: A document database using JSON, a MapReduce query using JavaScript, and an API that uses HTTP

* Couchbase: Based on JSON model

* RavenDB: A document-oriented database based on the. NET language

* MarkLogic: Used to store XML-based and document-centric information to support flexible patterns

Graph Database (graph)

* neo4j: A graph database that supports acid transactions

* InfiniteGraph: Used to maintain and traverse the relationship between objects, supporting distributed data storage

* Allegrograph: Combines memory and disk, provides high scalability, supports SparQ, rdfs++, and Prolog inference

Six, a simple comparison of nosql and SQL syntax

The basics of NoSQL are described earlier, using HBase and Oracle as examples to make simple comparisons of NoSQL and SQL syntax. The HBase database is considered one of the most secure NoSQL database products, and it has proven to be a powerful tool, especially in situations where Hadoop has been used. Today, it is an Apache top-level project with numerous developers and a thriving user community.

1. Create a table

If you want to create a table "MyTable" that contains an "info" field, then:

(1) The syntax in Oracle is:

CREATE TABLE MyTable

(

Info varchar (+) NOT NULL

);

(2) The syntax in HBase is:

Create ' mytable ', ' CF '

This command creates a table "MyTable" with a column family ("CF").

2. Write Data

If you want to write the 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" in the data cell for the "cf:info" column in the "first" row of the "mytable" table.

3. Read (check) the data

If you want to read a single piece of data from a 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 of the 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 '

The command outputs all the data.

4. Deletion of data

If you want to delete data from a 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 '

The command overwrites the old value with the most recent 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 ' where info = ' hellohbase ';

(2) The syntax in HBase is:

Put ' mytable ', ' first ', ' cf:info ', ' Hello Hbase1 '

The command overwrites the old value with the most recent value, which is equivalent to modifying the original data.

6. By deleting the 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 first "disable" the table, and then "drop" off.

As we can see, HBase's syntax is relatively simple, so it's perfectly possible to put all of the above commands into a shell script and have the commands run in batches. Here, let's take a specific look at the following:

The first step is to write a script called "command.sh" with the following contents:

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 ' mytable ', ' first ', ' cf:info ', ' Hello Hbase1 '

Disable ' mytable '

Drop ' mytable '

Eof

In the second step, upload the script to the user who installs HBase on the Linux machine, then execute the "Dos2unix command.sh" and "chmod 777command.sh" commands to convert the file format and assign permissions to the file.

Step three, 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, Value=hello hbase

1 row (s) in 0.0440 seconds

Scan ' mytable '

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 was executed in a matter of seconds, but all of the hbase commands we mentioned earlier are included, which shows the power of the batch process. We must have a good experience.

Vii. Summary

This article gives a comprehensive introduction to NoSQL and compares it to the SQL syntax. While most NoSQL data storage systems have been deployed in real-world applications, the following challenges remain to be addressed:

First, the existing Key-value database products are mostly for the specific application of self-government construction, lack of universality.

Second, there are limited features supported by the product (transaction characteristics are not supported), which has some limitations in its application.

Thirdly, there have been some research results and improved NOSQL data storage systems, but they are the corresponding solutions for different application needs, seldom consider the generality of the system from the whole, nor form a series of research results.

The second is the lack of strong theories such as relational databases (such as the Armstrong Axiom System), technology (such as mature heuristic-based optimization strategies, two-block protocol, etc.), and support for standard specifications such as the SQL language.

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

With the development of cloud computing, mobile Internet and other technologies, big data exist widely, and there are many new applications in cloud environment, such as social network, mobile service, collaborative editing and so on. These new applications also present new requirements for massive data management or cloud data management systems, and NoSQL databases have the opportunity to do so. We have reason to believe that the NoSQL database tomorrow will be more beautiful!

A NoSQL database overview and its comparison with SQL syntax

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.