Home > Database > SQL > body text

What are the characteristics of nosql database

青灯夜游
Release: 2022-11-28 19:44:10
Original
21011 people have browsed it

nosql features: 1. Flexible scalability; nosql removes the relational characteristics of relational databases, there is no relationship between data, and it can be easily expanded. 2. Flexible data model; NoSQL uses non-relational models such as key/value and column family, allowing different types of data to be stored in one data element. 3. NoSQL can rely on its good horizontal expansion capabilities to make full use of cloud computing infrastructure and integrate well into the cloud computing environment. 4. Nosql has very high reading and writing performance, especially when dealing with large amounts of data. 5. High availability.

What are the characteristics of nosql database

The operating environment of this tutorial: Windows 7 system, Dell G3 computer.

Introduction to NoSQL

NoSQL is a database management system design method that is different from relational databases. The general term for relational database. The data model it uses is not the relational model of traditional relational databases, but non-relational models such as key/value, column family, document, etc. NoSQL databases do not have a fixed table structure, there are usually no join operations, and they do not strictly adhere to ACID constraints. Therefore, compared with relational databases, NoSQL has flexible horizontal scalability and can support massive data storage.

What is ACID?

  • Atomicity of transactions (Atomicity): means that a transaction is either fully executed or not executed, which means that a transaction is impossible It stopped only halfway through. For example, if you withdraw money from an ATM, this transaction can be divided into two steps: 1 swipe the card, and 2 withdraw the money. It is impossible to swipe the card but the money does not come out. These two steps must be completed at the same time or not completed at all.
  • Consistency of transaction(Consistency): means that the running of the transaction does not change the consistency of the data in the database. For example, the integrity constraint a b=10, and a transaction changes a, then b should also change accordingly.
  • INDEPENDENCE(Isolation):The independence of transactions is also called isolation, which means that two or more transactions will not be executed in an interleaved manner. Because this may lead to data inconsistency.
  • Durability(Durability):The durability of a transaction means that after the transaction is executed successfully, the changes made by the transaction to the database are permanently saved in the database and will not be rolled back for no reason

Characteristics of NoSQL database

1) Flexible scalability

Traditional relational databases are usually difficult to achieve "horizontal expansion" due to their own design mechanisms. When facing a large-scale increase in database load, , it is often necessary to upgrade hardware to achieve "vertical expansion." NoSQLThe database was originally designed to meet the needs of "horizontal expansion", so it is inherently equipped with good horizontal expansion capabilities.

2)Flexible data model

Relational databases have standardized definitions and comply with various strict constraints. Although this approach ensures the data consistency requirements of the business system, the overly rigid data model also means that it cannot meet various emerging business needs. In contrast, NoSQL databases use non-relational models such as keys, /values, column families, etc., allowing different types of data to be stored in one data element. data.

3)Tightly integrated with cloud computing

Cloud computing has good horizontal expansion capabilities and can be freely scaled according to resource usage. Various resources can be dynamically added or withdrawn. NoSQL databases can rely on their own good horizontal expansion. Ability to make full and free use of cloud computing infrastructure, integrate well into the cloud computing environment, and build cloud database services based on NoSQL.

(4) Large data volume, high performance

nosql database has very high read and write performance, especially under large data volume, It also performs very well, mainly due to its non-relationship and simple database structure.

Usually nosql uses Query Cache.

nosql's Cache is record-level, a fine-grained Cache, so from this aspect, the performance of nosql is much higher.

(5) High availability

High availability is also an obvious feature of nosql. Nosql can be implemented very conveniently without affecting performance. Highly available architecture, typical examples include Cassandra and HBase models. High availability can also be achieved through models.

Reasons for the rise of NoSQL

1 Relational databases can no longer satisfy The requirements of Web2.0. Mainly manifested in the following aspects:

  • (1) cannot meet the management needs of massive data

  • For the above websites, it will soon be possible Generating more than 10# billion records, for a relational database, in a table with 10SQLQuery is extremely inefficient.

  • 2)cannot satisfy Requirements for high data concurrency

  • 3) cannot meet the requirements of high scalability and high availability

2, The key to relational database Features have become "tasteless" in the era of Web 2.0

The key features of relational databases include complete transaction mechanisms and efficient query mechanisms. However, the two key features that relational databases are proud of have become useless in the Web2.0 era, mainly in the following aspects:

(1) Web 2.0 website systems usually do not require strict database transactions

For many Web 2.0 websites, database transactions are no longer So important. Database transactions usually have a complex implementation mechanism to ensure database consistency, which requires a lot of system overhead. For Web 2.0 websites that contain a large number of frequent real-time read and write requests, the cost of implementing transactions is unbearable.

(2)Web 2.0 does not require strict real-time performance of reading and writing

For relational databases, once a data record is successfully inserted into the database, it can be queried immediately.

For Web 2.0, there is no such real-time reading and writing requirements.

(3) Web 2.0 usually does not contain a large number of complex SQL queries

Complex SQL queries usually contain multiple Table join operations. However, Web 2.0 websites have been designed to minimize or even avoid such operations, and usually only use primary key queries of a single table. Therefore, the query optimization mechanism of relational databases is difficult to make a difference in Web 2.0.

Comparison of NoSQL and relational databases

RDBMS: relational database

What are the characteristics of nosql database

What are the characteristics of nosql database

What are the characteristics of nosql database

##Comparison of NoSQL and relational databases Summary:

(1) Relational Database

Advantages: Based on the complete relational algebra theory, there are strict standards, supporting the four properties of transaction ACID, with the help of the index mechanism Can achieve efficient query, mature technology, technical support from professional companies

Disadvantages: Poor scalability, unable to support massive data storage, data model too rigid, unable to support Web2.0 applications, transaction mechanism affects the overall system Performance etc

2 NoSQLDatabase

##Advantages: Yes Supports ultra-large-scale data storage, the flexible data model can well support Web2.0 applications, and has strong horizontal expansion capabilities, etc.

Disadvantages: Lack of mathematical theoretical foundation, low performance of complex queries, mostly unable to achieve strong transaction consistency, difficult to achieve data integrity, technology is not yet mature, lack of professional team Technical support, difficult maintenance, etc.

(3) Relational databases and NoSQL databases each have their own advantages and disadvantages and cannot replace each other.

Relational database application scenarios

: Key business systems in telecommunications, banking and other fields need to ensure strong transaction consistency

NoSQL

Database application scenarios: Non-critical businesses of Internet companies and traditional companies (such as data analysis)

Adopt hybrid architecture

  • Case: Amazon uses different types of databases to support its e-commerce applications
  • For temporary data such as "shopping basket", use Key-value storage will be more efficient
  • The current product and order information is suitable for storage in a relational database

NoSQL The four major types of

NoSQLAlthough there are many databases, in summary, the typical NoSQLDatabases usually include key-value database, column family database, document database and graph database

1. Key-value database

Key-value database (Key-Value Database) has a specific Key and a pointer pointing to a specific Value in the table. Key can be used to locate Value, that is, to store and retrieve specific Value. Value is transparent and invisible to the database. Value cannot be indexed or queried, and can only be queried through Key. Value can be used to store any type of data, including integers, characters, arrays, objects, etc.

Application scenario:A session-oriented application (such as Web application) starts when the user logs in session and remains active until the user logs off or the session times out. During this time, the application stores all session-related data in main memory or in a database. Session data may include user profile information, messages, personalization data and themes, suggestions, targeted promotions and discounts. Each user session has a unique identifier. Session data cannot be queried on any key other than the primary key, so a fast key-value store is better suited for session data. In general, key-value databases may offer less overhead per page than relational databases.

What are the characteristics of nosql database

##2. Column family database

What are the characteristics of nosql database

##3. Document database

What are the characteristics of nosql database

##4. Graph database


What are the characteristics of nosql database

5. Comparative analysis of different types of databases


  • MySQL: was produced earlier and matured with the LAMP trend. Although there are no major improvements, the most used database on the emerging Internet
  • MongoDB: is a new thing that provides more flexibility Data model, asynchronous submission, geographical location index and other various functions
  • HBase: is a "bullying" elephant soldiers. Relying on the ecological environment of Hadoop, it can have good scalability. But just like the elephant soldier, the user needs to raise an elephant (Hadoop), to drive him
  • Redis: is a representative of key-value storage and has the simplest function. Provide random data storage. Just like a stick, there is no extra structure. But precisely because of this, its scalability is particularly good. Just like the golden cudgel in Wukong's hand, the big one can pierce the sky, and the small one can shrink into a needle

The three cornerstones of NoSQL

The so-called CAP refers to:

  • CConsistency) : Consistency means that any read operation can always read the result of the previously completed write operation. That is, in a distributed environment, data at multiple points is consistent , or in other words, all nodes have the same data at the same time
  • A:(Availability):Availability refers to obtaining data quickly and returning operation results within a certain time, ensuring that each request has a response regardless of success or failure;
  • ##P##Tolerance of Network Partition):Partition tolerance refers to when In the case of network partitioning (that is, some nodes in the system cannot communicate with other nodes), the separated system can also run normally, that is to say, the loss or failure of any information in the system will not affect the system The continued operation.
CAP

Theory tells us that it is impossible for a distributed system to meet the three requirements of consistency, availability and partition tolerance at the same time. Satisfying two of them at the same time is as the saying goes, "You can't have your cake and eat it too."

What are the characteristics of nosql database

When dealing with the problem of

CAP, there are a few obvious choices:

  • CA: that is, emphasizing consistency (C) and availability (A), give up partition tolerance (P), the simplest way is to put all transaction-related content on the same machine superior. Obviously, this approach will seriously affect the scalability of the system. Traditional relational databases (MySQL, SQL Server and PostgreSQL), all This design principle is adopted, so the scalability is relatively poor

  • CP: that is, the emphasis is on consistency sex (C) and partition tolerance (P), give up availability (A ), when a network partition occurs, the affected services need to wait for the data to be consistent, so they cannot provide external services during the waiting period

  • AP : That is, emphasizing availability (A) and partition tolerance (P), giving up consistency (C), allowing the system to return inconsistent data

##BASE

I mentioned ACID before, now let’s talk briefly about

BASE (B asically Availble, Soft-state, Eventual consistency)

##atomicityConsistency(/
##ACID

BASE

(Atomicity)

##Basically available
(

Basically A##vailable)

Consistency)Soft state

Flexible transaction(Soft state)

isolation(Isolation)

Eventual consistency(Eventual consistency)

Persistence(Durable)


## The basic meaning of

BASE is Basically available (Basically Availble), soft state (S oft-state) and eventual consistency (Eventual consistency) :

Basically available
       

Basically available means that when a part of a distributed system has a problem and becomes unavailable, other parts can still be used Normal use, that is, allowing partition failure to occur

Soft state
                                                     

soft-state)" is a formulation corresponding to "hard state (hard-state)". When the data stored in the database is in "hard state", data consistency can be guaranteed, that is, the data is always correct. "Soft state" means that the state can be out of sync for a period of time, with a certain lag

Eventual consistency

The types of consistency include strong consistency and weak consistency. The main difference between the two is whether subsequent operations can obtain the latest data under highly concurrent data access operations. For strong consistency, after an update operation is performed, other subsequent read operations can guarantee that the latest data after the update is read; conversely, if it cannot be guaranteed that subsequent accesses read the latest data after the update, then It's weak consistency. Final consistency is just a special case of weak consistency, which allows subsequent access operations to temporarily fail to read the updated data, but after a period of time, the updated data must eventually be read .

For more programming-related knowledge, please visit: Programming Teaching! !

The above is the detailed content of What are the characteristics of nosql database. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!