The difference between SQL database and NoSQL database

The full name of SQL is Structured Query Language, a structured query language, a database query and programming language used to access data and query, update and manage relational databases.

SQL databases refer to relational databases, such as MYSQL, oracle, etc., and NoSQL (not only SQL) databases refer to non-relational databases, such as MangoDB, Redis, etc.

The main differences between the two are as follows:

1. Type

SQL databases are mainly called relational databases; NoSQL databases are mainly called non-relational databases or distributed databases.

2. Language

SQL database definition and operation are based on the structured query language (SQL) of the data. From the side, this language is very powerful. SQL is one of the most versatile and widely used options, making it a safe choice, especially for complex queries. But on the other hand, it may be restrictive. SQL requires you to use a predefined schema to determine the structure of the data before using it. In addition, all your data must follow the same structure . This may require a lot of preliminary preparation, which means that structural changes are difficult and cause damage to the entire system.

NoSQL databases have a dynamic mode of unstructured data. Data is stored in multiple ways, which means it can be document-oriented, column-oriented, graph-based or organized as KeyValue storage. This flexibility means that documents can be created without first defining the structure. Each document can also have its own unique structure . The syntax varies from database to database , and you can add fields at any time.

3. Scalability

SQL databases are all vertically scalable . The load of a single server can be increased by adding functions such as RAM, CPU or SSD. NoSQL databases can be scaled horizontally . You can handle more traffic by sharding or adding more servers to the NoSQL database, so NoSQL databases are more suitable for big data storage.

4. Structure

SQL databases are table- based, on the other hand NoSQL databases are key-value pairs , document-based , graph databases or wide column storage . This makes relational SQL databases a better choice for applications that require multi-line transactions (such as accounting systems) or legacy systems built for relational structures.

5. Follow the attributes

SQL databases follow the ACID properties (atomicity, consistency, isolation and durability), while NoSQL databases follow the Brewers CAP theorem (Consistency, Availability, and Partition tolerance).

For specific introduction of ACID and CAP, please refer to https://cloud.tencent.com/developer/article/1165624

6. Support

All SQL databases from its vendors provide good support. In addition, there are many independent consultations that can help with large-scale deployments using SQL databases, but for some NoSQL databases, you still need to rely on community support, and only a limited number of external experts can be used to set up and deploy large-scale NoSQL deployments.

Some examples of SQL databases include PostgreSQL, MySQL, Oracle, and Microsoft SQL Server. Examples of NoSQL databases include Redis, RavenDB Cassandra, MongoDB, BigTable, HBase, Neo4j and CouchDB.

7. Applicable scenarios

Projects suitable for development using SQL:

  • Database mode, the structure can be pre-defined, or can be a relatively fixed project
  • Data consistency required
  • Standard mature technology with good developer experience and technical support

Projects suitable for NoSQL development:

  • Irrelevant, uncertain and evolving data needs
  • Simpler or more relaxed projects that can start programming quickly
  • Speed ​​and scalability are crucial

Guess you like

Origin blog.csdn.net/qq_24852439/article/details/104384468