NSQL-MongoDB database Introduction

A relational database to follow the rules ACID

Services in English is transaction, and the real world of trading is very similar, it has the following four characteristics:

. 1 , A (Atomicity) atomicity

Atomic is easy to understand, that is to say in the affairs of all the operations done either all or nothing, a successful transaction is a transaction where the conditions of all the operations are successful, as long as one operation fails, the entire transaction will fail, need to return roll.

Such as bank transfer, account transfer from A to B account 100 yuan, is divided into two steps: 1) taking account A 100; 2) deposit $ 100 to $ B account. These two steps are completed either together or do not finish together, if only to complete the first step, the second step fails, the money will somehow less than 100 yuan.

 

2 , C (Consistency) consistency

Consistency is also easier to understand, that has been in the database to a consistent state, run the transaction will not change the original database consistency constraints.

Example, an existing integrity constraints a + b = 10, a transaction change if a, then changes have to b, so that after the end of the transaction is still satisfying a + b = 10, otherwise, the transaction fails.

3 , the I (Isolation) independence

Refers to the so-called independence will not affect each other concurrent transactions, data to be accessed if a transaction is being modified by another transaction, as long as the other uncommitted transactions, access to the data it does not affect the transaction is not submitted .

For example, now there is a transaction is transferred from account A to account B 100 yuan, in the case of this transaction has not been completed, if B at this time to check their accounts, can not see the new addition of $ 100.

. 4 , D (Durability Rev) Persistence

Persistence means that once the transaction commits, modify it made will be permanently stored on the database, it will not be lost even if downtime occurs.

Two NOSQL database

NOSQL broad definition of non-relational databases, he broke the relational database with ACID database theory long-term monopoly of the market situation has long NOSQL database storage does not require fixed table structure, generally there is no connection to operate. Relational databases have unmatched performance advantage in the big two data access.

https://img-blog.csdnimg.cn/20190331211559859.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3N5amhjdA==,size_16,color_FFFFFF,t_70

   Mongdb is a high-performance, open source, schema-document database. BSON document is a document (json binary), save the data: key-value.

It extended a lot of features, such as secondary index (secondary index), range queries (range query), sorting, polymerization, has a sixth spatial index.

 

Three RDBMS vs NoSQL

The RDBMS 
- highly organized structured data 
- Structured Query Language (SQL) (SQL) 
- data and relationships are stored in a separate table. 
- Data Manipulation Language, Data Definition Language 
- strict consistency
- Basic Services

NoSQL 
- represents not just SQL
- no declarative query language
- there is no predefined model
- key - value pair, column storage, document storage, graphics, database
- eventual consistency, rather than the ACID properties
- unstructured and can not predictable data
- the CAP Theorem 
- high performance, high availability and scalability

 

Four CAP Theorem (CAP theorem)

In computer science, CAP Theorem (CAP theorem), also known as Brewer Theorem (Brewer's theorem), it is pointed out that for a distributed computing system, can not simultaneously meet the following three points:

  • Consistency (Consistency)  (all nodes with the same data at the same time)
  • Availability (Availability)  (ensure that every request has a response regardless of success or failure)
  • Separated tolerance (Partition Tolerance)  (system loss or failure of any of the information does not affect the continued operation of the system)

CAP core theory is: a distributed system can not simultaneously satisfy consistency, availability, fault tolerance, and partition these three requirements, can only meet two good while.

Therefore, in accordance with the principles of the CAP into a NoSQL database to meet the CA principle, to meet the principles of CP and AP meet the principles of three categories:

  • CA - single-point cluster, meet consistency, availability of the system, usually less powerful on scalability.
  • CP - meet the system consistency, tolerant partition, performance is usually not particularly high.
  • AP - meet availability, partition tolerance of the system, usually some possible low consistency requirements.

Five BASE

BASE:Basically Available, Soft-state, Eventually Consistent。 由 Eric Brewer 定义。

CAP core theory is: a distributed system can not simultaneously satisfy consistency, availability, fault tolerance, and partition these three requirements, can only meet two good while.

BASE is a NoSQL database is usually the principle of availability and consistency of weak requirements:

  • Basically Availble - basic available
  • Soft-state - soft state / flexible transactions. "Soft state" can be understood as "no connection", and "Hard state" is "connection-oriented" in
  • Eventual Consistency - eventual consistency is the ultimate goal of ACID.

 

ACID vs BASE

ACID

BASE

Atomicity ( A tomicity)

Basic Available ( B asically  A vailable)

Consistency ( C onsistency)

Soft state / flexible transaction ( S OFT State)

Isolation ( the I solation)

The final consistency ( E ventual Consistency)

Persistent ( D urable)

 
Published 37 original articles · won praise 0 · Views 2414

Guess you like

Origin blog.csdn.net/syjhct/article/details/88936143