Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the advantages and disadvantages of relational database and non-relational database

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the relevant knowledge of "what are the advantages and disadvantages of relational database and non-relational database". The editor shows you the operation process through an actual case, and the operation method is simple, fast and practical. I hope that this article "what are the advantages and disadvantages of relational database and non-relational database" can help you solve the problem.

I. Relational database 1. Concept

Relational database: refers to the database that uses the relational model to organize data, which is the most widely used database system in all kinds of databases at present. To put it simply, the relational model refers to the two-dimensional table model, and a relational database is a data organization composed of two-dimensional tables and their relationships. The mainstream databases used now are relational databases, such as SQL Server, Mysql, Oracle, DB2, Sybase and so on.

Concepts commonly used in relational models:

Relationship: can be understood as a two-dimensional table, each relationship has a relationship name, which is commonly referred to as the table name.

Tuple: can be understood as a row in a two-dimensional table, often referred to as a record in a database.

Attribute: can be understood as a column in a two-dimensional table and is often referred to as a field in a database.

Field: the value range of an attribute, that is, the value limit of a column in the database.

Keyword: a set of attributes that uniquely identify a tuple, often called a primary key in a database, and consisting of one or more columns.

Relationship pattern: refers to the description of a relationship. Its format is: relationship name (attribute 1, attribute 2. Attribute N), which is called the table structure in the database.

2. The characteristics of relational database.

Relational database is a database system that supports relational model. The relational model is a model that represents the relationship between entities and entities by a two-dimensional table. Using a two-dimensional table to store data is intuitive and easier for users to understand. The advantages of using relational databases are mainly shown in the following features:

(1) convenience of operation. Through the development of application programs and database connections, users can easily operate the data in the database, especially for those who do not have a database foundation, they can also operate directly in the database through the database management system.

(2) easy to maintain. Relational database provides entity integrity, referential integrity and user-defined integrity in integrity constraints. Through integrity constraints, the redundancy of data storage and the probability of data inconsistency can be greatly reduced.

(3) flexibility of accessing data. Relational databases provide objects such as views, stored procedures, triggers, indexes and so on, which make data access more flexible.

3. The bottleneck of relational database

(1) the demand for high concurrent read and write of database

Web2.0 website needs to generate dynamic pages and provide dynamic information in real time according to users' personalized information, so it is impossible to use the static technology of dynamic pages, so the concurrent load of the database is very high, often reaching tens of thousands of read and write requests per second. At this time, the disk on the server simply can not bear so many read and write requests.

(2) the need for efficient storage and access of massive data

For large social networking sites, users generate a large amount of user dynamics every day. With the continuous increase and decrease of users, there may be hundreds of millions of records in a data table. For relational databases, it is very inefficient to query SQL in a table with hundreds of millions of records.

(3) High scalability and availability

In the web-based structure, the database is the most difficult to scale out. When the number of users and visitors of an application system is increasing day by day, the database has no way to expand the performance and load capacity as simply as web server by adding more hardware and service nodes.

4. Relational data follow the ACID principle.

Transaction is transaction in English, which is similar to real-world transaction. It has the following four features:

1. A (Atomicity) atomicity

Atomicity is easy to understand, that is, all operations in the transaction are either completed or not done. The condition for the success of a transaction is that all operations in the transaction are successful. As long as one operation fails, the whole transaction fails and needs to be rolled back. For example, a bank transfer of 100 yuan from An account to B account is divided into two steps: 1) withdraw 100 yuan from An account; 2) deposit 100 yuan to B account. These two steps are either completed together or not together. If only the first step is completed and the second step fails, the money will be inexplicably less than 100 yuan.

2. C (Consistency) consistency

Consistency is also easy to understand, that is, the database should be in a consistent state all the time, and the operation of the transaction will not change the original consistency constraints of the database. For example, the existing integrity constraint a+b=10, if a transaction changes a, then b must be changed so that the transaction still satisfies a+b=10 after the transaction ends, otherwise the transaction fails.

3. I (Isolation) independence

The so-called independence means that concurrent transactions will not affect each other. If the data accessed by one transaction is being modified by another transaction, as long as another transaction is not committed, the data accessed by it will not be affected by the uncommitted transaction. For example, there is a transaction that transfers 100 yuan from An account to B account. In the case that the transaction has not been completed, if B inquires about his own account at this time, he will not see the new 100 yuan.

4. D (Durability) persistence

Persistence means that once a transaction is committed, its changes will be permanently stored on the database and will not be lost even if there is an outage.

II. NoSQL database

NoSQL is used to refer to non-relational databases that are non-relational, distributed, and generally do not guarantee compliance with ACID principles. NoSQL, sometimes referred to as the abbreviation of Not Only SQL, is a general term for database management systems that are different from traditional relational databases. NoSQL is used to store very large-scale data. Google or Facebook, for example, collect terabytes of data for their users every day. These types of data stores do not require fixed schemas and can be scaled out without redundant operations. Non-relational database puts forward another concept, for example, it is stored in the way of key-value pairs, and the structure is not fixed, each tuple can have different fields, and each tuple can add some of its own key-value pairs as needed, so it will not be limited to a fixed structure, and can reduce some time and space overhead. In this way, users can add the fields they need as needed. However, due to few constraints, the non-relational database is also unable to provide a query for field attribute values like the where provided by SQL. And it is difficult to reflect the integrity of the design. It is only suitable for storing some relatively simple data, and SQL database is more suitable for the data that needs to be queried more complex.

1. Distributed system

A distributed system (distributed system) consists of multiple computers and communication software components connected through a computer network (local network or wide area network).

Distributed system is a software system based on network. Because of the characteristics of the software, the distributed system has a high degree of cohesion and transparency.

Therefore, the difference between a network and a distributed system has more to do with high-level software (especially the operating system) than hardware.

Distributed systems can be applied to different platforms such as Pc, workstations, local area networks and wide area networks.

2. Advantages of distributed computing

Reliability (fault tolerance):

An important advantage of distributed computing system is reliability. The system crash of one server does not affect the rest of the server.

Scalability:

In distributed computing systems, more machines can be added as needed.

Resource sharing:

Sharing data is essential for applications such as banking and booking systems.

Flexibility:

Because the system is very flexible, it is easy to install, implement and debug new services.

Faster speed:

A distributed computing system can have the computing power of multiple computers, which makes it faster than other systems.

Open system:

Because it is an open system, the service can be accessed locally or remotely.

Higher performance:

Compared with centralized computer network clusters, it can provide higher performance (and better cost performance).

3. Shortcomings of distributed computing

Troubleshooting:

Troubleshooting and diagnosing problems.

Software:

Less software support is the main disadvantage of distributed computing systems.

Network:

Network infrastructure problems, including: transmission problems, high load, information loss and so on.

Security:

The characteristics of the development system make the distributed computing system have some problems, such as the security of data and the risk of sharing.

4. Comparison between relational database and non-relational database 4.1. Relational database

-highly organized structured data

-structured query language (SQL) (SQL)

-data and relationships are stored in separate tables.

-data manipulation language, data definition language

-strict consistency

-basic transaction

4.2 、 NoSQL

-represents more than just SQL.

-No declarative query language

-there are no predefined patterns

-key-value pair storage, column storage, document storage, graphics database

-final consistency, not ACID attribute

-unstructured and unpredictable data

-CAP theorem

-High performance, high availability and scalability

The most important feature of relational database is transaction consistency: the traditional read and write operations of relational database are transactional and have the characteristics of ACID, which makes relational database can be used in almost all systems that require consistency, such as typical banking systems.

However, in web applications, especially in SNS applications, consistency is not so important. It is tolerable that what user A sees is inconsistent with user B seeing the same user C content update, or that the time difference between two people seeing the same friend's data update is tolerated by a few seconds. Therefore, the biggest feature of relational database is useless here, at least not so important.

On the contrary, the huge price paid by relational databases to maintain consistency is their poor read and write performance, while SNS applications such as Weibo and facebook require extremely high concurrent read and write capabilities, and relational databases can no longer cope with them. (in terms of reading, traditionally, in order to overcome the shortcomings of relational databases and improve performance, one level of memcache is added to static web pages, while in SNS, it changes too fast. Memchache is powerless, so a new data structure storage must be used instead of relational databases.

Another characteristic of relational database is that it has a fixed table structure, so its expansibility is very poor, but in SNS, the upgrade of the system and the increase of functions often mean great changes in data structure, which is difficult for relational databases to cope with and requires new structured data storage.

Therefore, the non-relational database arises at the historic moment, because it is impossible to use a kind of data structured storage to meet all the new requirements, therefore, the non-relational database is not strictly a kind of database, it should be a collection of data structured storage methods.

It must be emphasized that the persistent storage of data, especially the persistent storage of massive data, still requires the use of relational databases.

5. Advantages / disadvantages of NoSQL

Advantages:

-High scalability

-distributed computing

-low cost

-Architectural flexibility, semi-structured data

-there are no complicated relationships.

Disadvantages:

-No standardization

-Limited query capabilities (so far)

-ultimately consistent is an unintuitive program

This is the end of the introduction to "what are the advantages and disadvantages of relational and non-relational databases". Thank you for your reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report