What does a non-relational database role look like

What are the two main types of databases?

Databases are mainly categorized into relational databases and non-relational databases (NoSQL).

1. Relational databases

Relational databases, stored in a format that visually reflects the relationships between entities. Relational databases and common tables are more similar, relational databases in the table with the table is a lot of complex correlation between the relationship.

Common relational databases include Mysql, SqlServer, and so on. In light or small applications, the use of different relational databases does not have a significant impact on the performance of the system, but when building large applications, you need to choose the appropriate relational database based on the business needs and performance requirements of the application.

2, non-relational database (NoSQL)

This refers to the distributed, non-relational, not guaranteed to follow the ACID principle of data storage system. NoSQL database technology and CAP theory, consistency hash algorithms have a close relationship. NoSQL database is suitable for the pursuit of speed and scalability, the business of the application of the changeable scenarios.

(A) Redis-NoSql what is, what can do, and the difference between relational database

Big data era, short videos and a large number of pictures lead to a very large data table, frequent queries lead to the traditional relational database is difficult to meet the needs of the non-relational database came into being.Redis database is a NoSQL is a kind of, in the CAP principle of distributed databases, Redis to meet the strong consistency and high availability, strong consistency is to ensure the quality of the data, high availability that stability, this paper briefly introduces the non-relational database is what, what can be done, and the difference between relational databases.

A definition of NoSQL

NoSQL (NotOnlySQL), meaning “not only SQL”, refers to non-relational databases in general.NoSQL databases have been created to solve the challenges posed by large-scale data collections with multiple data types, such as Google or Facebook, which collects millions of users every day. Facebook collects trillions of bits of data for their users every day, and these types of data stores don’t require a fixed schema and can scale horizontally without redundancy.

The advantages of NoSQL

1. Ease of Scaling

There are many different kinds of NoSQL databases, but one common feature is that the relational nature of relational databases is removed. There is no relationship between the data, which makes it very easy to expand, invariably bringing scalability at the architectural level.

2. High performance in large data volumes

NoSQL databases have very high read and write performance, especially in large data volumes, write 80,000 a second, read 160,000 times

3. Diverse and flexible data models

NoSQL does not need to establish fields for the data to be stored in advance, and can be customized at any time according to the storage of the data format, and the relational database. In relational databases, it is a nightmare to add or delete fields, such as adding a cell phone number field to a table that stores information about WeChat users.

4. RDBMS and NoSQL

Relational database & non-relational database comparison

Three, 3V + 3 high

Massive: microblogging

Diversified: the presentation of pictures, text, etc., the terminal is the cell phone, computer, pads and so on.

Real-time: 12306’s railroad information needs to be updated in real time, but it can’t do absolute real-time, only quasi-real-time.

High concurrency: 12306 is highly concurrent when grabbing train tickets

Highly scalable (scalability):

Lateral expansion: for multiple machines, multiple machines are integrated into a cluster

Vertical expansion: for a machine, 2G is not enough to plug in two 4G to 8G, but there is always an end to vertical expansion in the long run

NoSQL data model introduction

(a) to an e-commerce customer, order, ordering, address model to compare relational and non-relational database database

1. relational database:

2. non-relational database:

like a jason string, known as the aggregation model

(ii) )Thinking

Why the above scenario can be handled by the aggregation model?

1.In relational database use leftjoin association query, but it involves multiple tables, the query statement is very long and complex

2.Cross library

3.Distributed transaction can’t support too much concurrency

-4.NoSQL as long as you check the ID of the customer’s information, all of them are put together, you don’t need to check like relational database. A lot of tables

(C), aggregation model

1.KV key-value pairs

2. Document-based database (Bson format is more): see the above screenshot

Monddb, the most relational database like the relational database of non-relational databases

3. Columns storage database:

4. Graph-relational databases:

Like our complex relatives interpersonal relationships, such as: what topics on Twitter your friends focus on

V. CAP principle CAP + BASE in distributed databases

(a) CAP

ACID: traditional relational databases


CAP can only be satisfied by three of the two, and because current network hardware will certainly be delayed packet loss and other issues, so partition fault tolerance is what we must achieve, we can only trade-off between consistency and availability.

CA: traditional Oracle database

AP: the choice of most website architectures

CP: Redis, Mongodb

Strong consistency (C), Taobao commodity likes don’t need to do strong consistency; but the company’s daily morning and evening clocking software needs to be strong consistency, otherwise it affects the staff’s KPIs<

High availability (A), the site can not be crashed

Partition tolerance (P)

Added: the choice between C and A


Double eleven at that time may be the number of commodity likes 10,000, but only counted to 6,000, it is a weak consistency, but the peak of the end of the data is still wanting to make the data is not that outrageous, so the BASE is most important. Plus BASE, BASE is the most important is the final execution

Sacrifice C for AP

Clustering is equivalent to the previous load balancing

(a) Redis-NoSql is what it is, what it can do, and the difference with relational databases

Tags: operation is simple oracle database data format network high performance fields Partitioned Clusters

Why use a non-relational database

Traditional relational databases are not enough to cope with web2.0 websites, especially the ultra-large scale and high concurrency SNS-type web2.0 purely dynamic websites, exposing a lot of insurmountable problems, such as:

1, Highperformance- high concurrency of the database read and write demands

Web2.0 websites have to generate dynamic pages and provide dynamic information in real time based on users’ personalized information, so it is basically impossible to use dynamic page static technology. demand

web2.0 website to generate dynamic pages and provide dynamic information in real time according to the user’s personalized information, so basically can not use dynamic page static technology, so the database concurrent load is very high, often to reach tens of thousands of read and write requests per second. Relational database to cope with tens of thousands of SQL queries can barely hold up, but to cope with tens of thousands of SQL write data requests, hard disk IO has been unable to withstand. In fact, for ordinary BBS sites, there is often a demand for highly concurrent write requests.

2. HugeStorage – the need for efficient storage and access to massive amounts of data

For large SNS sites, every day users generate massive amounts of user dynamics, the foreign Friendfeed, for example, a month up to 250 million user dynamics, for the relational database, in a table of 250 million records inside the SQL query, the efficiency is extremely low. SQL queries in a table of 250 million records for a relational database, the efficiency is extremely low and even intolerable. For example, the user login system of a large web site, such as Tencent, Shanda, can easily be hundreds of millions of accounts, relational databases are also very difficult to cope with.