Classic interview: There are several key differences between relational databases (RDBMS) and non-relational databases (NoSQL)

There are several key differences between relational databases and non-relational databases (NoSQL)

- Data model:

  • Relational databases use a tabular structure, where data is organized in rows and columns, and use predefined schemas to define the data structure. Relationships between data are established through primary keys and foreign keys.
  • Non-relational databases use different data models, such as key-value, document-oriented, column-family, or graph. This flexibility allows storage and retrieval of unstructured and semi-structured data.

- Data consistency and transaction support:

  • Relational databases emphasize data consistency and integrity, and follow the ACID (atomicity, consistency, isolation, and durability) characteristics. Atomic operations that support transactions are either executed successfully or rolled back.
  • Non-relational databases generally focus more on scalability and performance, and relax consistency requirements. Some NoSQL databases provide flexible transactions or eventual consistency to keep data consistent.

- Scalability:

  • Relational databases usually adopt vertical scaling, that is, to improve database performance by increasing hardware resources (such as CPU and memory). There are certain physical limitations to this way of scaling.
  • Non-relational databases generally adopt horizontal scaling, that is, to distribute data and load by adding server nodes, thereby improving performance and capacity. This expansion method is more suitable for large-scale data processing.

- Flexibility and handling of semi-structured data:

  • A relational database requires a predefined schema and requires data to conform to that schema. If the data structure changes, modifications to the database schema may be required.
  • Non-relational databases have no strict restrictions on data structures and can accommodate data of different structures. This flexibility makes it easier to work with semi-structured data.

- Query language:

  • Relational databases usually use Structured Query Language (SQL) to query and manipulate data. SQL provides powerful query capabilities and rich operation functions.
  • Query languages ​​for non-relational databases vary by database type. Some NoSQL databases use a SQL-like query syntax, while others may use a custom query language or API.

Guess you like

Origin blog.csdn.net/a203206868/article/details/131556146