NoSQL database overview and its comparison with SQL syntax, nosql overview SQL syntax

Source: Internet
Author: User
Tags add time

NoSQL database overview and its comparison with SQL syntax, nosql overview SQL syntax

Abstr:]

HBase is a highly reliable, high-performance, column-oriented, and Scalable Distributed Storage System. It is also one of the well-known NoSQL databases. The emergence of NoSQL databases is to solve the challenges posed by multiple data types in large-scale data sets, especially the difficulties of big data applications.

This article briefly introduces the definition, classification, features, and popular NoSQL database systems of NoSQL databases, and compares the NoSQL and SQL syntaxes, it provides a useful reference for learning NoSQL databases.

 

I. emergence of NoSQL

Relational Database systems have achieved great success in solving data storage, services, and handling problems over the years. Some large companies use relational databases to establish their own systems, such as online transaction processing systems and backend analysis application systems. The online transaction processing (OLTP) system is used to record transaction information in real time. The expectation for such systems is the ability to quickly return response information (generally within milliseconds ). The OLAP system is used to analyze and query stored data. OLAP is a category of business intelligence. data needs to be researched, processed, and analyzed to collect information and further drive business decision-making.

The internal design of relational databases is determined by relational algorithms. These systems need to pre-define a schema and the types of data to comply. SQL is the standard way to interact with these systems. However, when the object-link mismatch problem occurs, SQL is not the best way to express the access mode. For example, relational databases cannot work well in the hot Big Data Field.

Common definitions of big data include: first, big data means that the data is big enough. You have to study it to get some insights from the data. Second, big data is no longer applicable to data on a single machine. These ideas are incomplete. We need to consider data in a fundamentally different way and consider data from the perspective of how to drive commercial value. Such data is big data.

In the big data field, the system must be able to adapt to different types of data formats and data sources, without the need to strictly define the mode in advance, and be able to process large-scale data. In this way, NoSQL emerged.

 

Ii. NoSQL Definition

NoSQL (NoSQL = Not Only SQL), meaning "Not just SQL", is a brand new revolutionary database movement. NoSQL advocates the use of non-relational data storage. Most database technologies do not support ACID (atomicity, consistency, isolation, and durability), and most of them are open-source projects, known as NoSQL as a whole.

 

Iii. NoSQL Classification

NoSQL databases are generally divided into four categories: Key-Value storage database, column storage database, document database, and Graph database. Their data models, advantages and disadvantages, and typical application scenarios are shown in table 1.

Table 1 NoSQL Database Analysis

Category

Data Model

Advantages

Disadvantages

Typical application scenarios

Key-Value storage database

Key-to-Value pairs, which are usually implemented in the hash table.

Fast search

Unstructured data (usually treated as strings or binary data only)

Content caching is mainly used to process high access loads of a large amount of data, and also for some log systems.

Column storage database

Stores data in a column cluster and stores data in the same column.

Fast search speed, high scalability, and easy distributed Expansion

Relatively limited functions

Distributed File System

Document Database

Key-Value pairs corresponding to Key-Value. Value is structured data.

The data structure requirements are not strict, and the table structure is variable (you do not need to pre-define the table structure like a relational database)

Low query performance and lack of unified query syntax

Web Applications

Graph database

Graph Structure

Use graph structure algorithms (such as Shortest Path addressing and N-degree link lookup)

Most of the time, you need to calculate the entire graph to obtain the required information. In addition, this structure is not good for Distributed cluster solutions.

Social networks, recommendation systems, etc.

 

 

Iv. Features of NoSQL

NoSQL databases do not have a unified architecture, but they all share some of the common features shown in table 2.

Table 2 NoSQL features

Features

Description

No pre-defined mode is required

You do not need to define the data mode or pre-define the table structure. Each record in the data may have different attributes and formats.

No shared Architecture

NoSQL stores data on local servers, improving system performance.

Elastic and scalable

You can dynamically add or delete nodes when the system is running. Data can be automatically migrated without downtime Maintenance

Partition

NoSQL databases partition data, distribute records on multiple nodes, and replicate data while partitioning data.

Asynchronous replication

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

BASE

Compared with the ACID feature, NoSQL databases guarantee the BASE feature (BASE is the final consistency and soft transactions)

 

 

V. Common NoSQL Databases

Suitable for NoSQL databases: (1) simple data models; (2) IT systems with higher flexibility; (3) High database performance requirements; (4) high Data Consistency is not required. (5) for a given key, it is easier to map an environment with complex values.

Common NoSQL databases are shown in table 3.

Table 3 common NoSQL Databases

Category

Instance

 

 

 

 

 

Key-Value storage database

* Riak: an open-source and Distributed Key-value database that supports data replication and fault tolerance

* Redis: an open-source Key-value storage database that supports master-slave replication, transactions, Pub/Sub, and Lua scripts, and allows you to add time limits to keys.

* Dynamo: a key-value distributed storage database is directly implemented by the Amazon Dynamo database.

* Oracle NoSQL Database: a key-value NoSQL Database from Oracle that supports transaction ACID and JSON

* Oracle NoSQL Database: provides data backup and Distributed Key-value storage systems.

* Voldemort: provides data backup and Distributed Key-value storage systems.

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

 

 

 

 

 

Column storage database

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

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

* Amazon SimpleDB: A non-Relational Data Storage

* Apache Accumulo: ordered, Distributed Key-value data storage, based on Google's BigTable Design

* Hypertable: an open-source and scalable database that imitates Bigtable and supports sharding.

* Azure Tables: Provides NoSQL performance for applications that require massive unstructured data storage

 

 

 

Document Database

* MongoDB: open-source and document-oriented

* CounchDB: a json document database that uses Javascript For MapReduce queries. It is also an API that uses HTTP

* Couchbase: JSON-based model

* RavenDB: A. net-based document-oriented database

* MarkLogic: used to store XML-based and document-centric information and supports flexible modes.

 

Graph database

* Neo4j: A graph database that supports ACID transactions

* InfiniteGraph: used to maintain the relationship between objects and traverse objects. It supports distributed data storage.

* AllegroGraph: combines memory and disks to provide high scalability. It supports SPARQ, RDFS ++, and Prolog reasoning.

 

Vi. simple comparison of NoSQL and SQL syntax

This section describes the basic information about NoSQL. The following uses HBase and ORACLE as examples to compare the syntax of NoSQL and SQL. HBase database is considered to be one of the most secure NoSQL database products. It has been proven to be a powerful tool, especially when Hadoop is used. Today, it is already a top-level Apache project with a large number of developers and thriving user communities.

1. Create a table

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

(1) ORACLE Syntax:

Create table mytable

(

Info varchar (30) not null

);

(2) syntax in HBase:

Create 'mytable', 'cf'

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

 

2. Write Data

If you want to write "hello hbase" to the table:

(1) ORACLE Syntax:

Insert into mytable (info) values ('Hello hbase ');

(2) syntax in HBase:

Put 'mytable', 'First ', 'cf: info', 'Hello hbase'

This command inserts "hello hbase" in the "cf: info" column of "first" in the "mytable" table ".

 

3. Read (query) data

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

(1) ORACLE Syntax:

Select * from mytable where info = 'Hello hbase ';

(2) syntax in HBase:

Get 'mytable', 'First'

This command outputs the data unit of the row.

 

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

(1) ORACLE Syntax:

Select * from mytable;

(2) syntax in HBase:

Scan 'mytable'

This command outputs all the data.

 

4. delete data

To delete data from a table:

(1) ORACLE Syntax:

Delete from mytable where info = 'Hello hbase ';

(2) syntax in HBase:

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 data

If you want to modify data in a table:

(1) ORACLE Syntax:

Update mytable set info = 'Hello hbase1 'where info = 'hellohbase ';

(2) syntax in HBase:

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 a table

To delete a table:

(1) ORACLE Syntax:

Drop table mytable;

(2) syntax in HBase:

Disable 'mytable'

Drop 'mytable'

This command first disable the table and then drop it.

 

We can see that the syntax of HBase is relatively simple, so we can put all the above commands into a shell script and let the commands be executed in batches. Next, we will perform the following operations:

Step 1: write a script named "command. sh" with the following content:

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

 

Step 2: Upload the script to the user who installs HBase on the Linux machine and execute "dos2unix command. sh and chmod 777command. sh command to convert the file format and grant permissions to the file.

 

Step 3: 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 execution process took only a few seconds, but all the HBase commands we mentioned earlier included them. This shows the power of batch processing. You must have a good understanding.

 

VII. Summary

This article gives a comprehensive introduction to NoSQL and compares its differences with SQL syntax. Although most NoSQL data storage systems have been deployed in practical applications, the following challenges still need to be solved:

First, most existing key-value database products are built for specific application autonomy, and lack of universality.

Second, existing products have limited functions (transactions are not supported), which leads to some limitations in their applications.

Third, there have been some research achievements and improved NoSQL data storage systems, but they are all corresponding solutions for different application needs, and seldom consider the universality of the system from the global perspective, there are no serialized research results.

Fourth, lack of strong theories like relational databases (such as armstrong systems) and technologies (such as mature heuristic optimization policies and two block blocking protocols), standard specifications (such as SQL language) support.

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

 

With the development of cloud computing, mobile Internet, and other technologies, big data is widely used. At the same time, new applications in many cloud environments have emerged, such as social networks, mobile services, and collaborative editing. These new applications have also raised new demands for massive data management or cloud data management systems, and NoSQL databases have the opportunity to make a big difference in these aspects. We have reason to believe that the future of NoSQL databases will be even better!

 

 

-------------------------

My public account: zhouzxi. Please scan the following QR code:

 

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

Related Article

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.