In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly shows you the "Example Analysis of ACID Theory and CAP Theory in Database". The content is simple and easy to understand, and the organization is clear. I hope it can help you solve your doubts. Let Xiaobian lead you to study and learn the article "Example Analysis of ACID Theory and CAP Theory in Database".
Transaction:
Transaction is a unit of concurrency control and a user-defined sequence of operations. These operations are either done or not done, and are an inseparable unit of work. In relational databases, a transaction can be a SQL statement, a set of SQL statements, or an entire program. When updating multiple tables, one execution failed. To preserve data integrity, transaction rollback is required.
ACID: Four features in an RDBMS
ACID refers to the reduction of only four elements of correct execution of transactions in the database, including Atomicity, Consistency, Isolation, and Durability. A database that supports transactions must, must satisfy these four characteristics, otherwise the correctness of the data cannot be guaranteed during transaction processing.
Atomicity:
All operations in the transaction are either complete or incomplete. It is impossible to stop at some intermediate stage. If an error occurs during the execution of the transaction, it will be rolled back to the state before the transaction started, as if the transaction had never been executed.
Examples:
A transfers $100 to B.
Consistency:
The integrity constraints of the database are not broken before the transaction begins and after the transaction ends.
Isolation:
Isolate state execution transactions so that they appear to be the only operations performed by the system at a given time. If there are two transactions running at the same time and performing the same function, the isolation of the transactions will ensure that each transaction is considered in the system as the only transaction in use. This property sometimes becomes serialized, and to prevent confusion between transaction operations, requests must be serialized or serialized so that only one request is for the same data at a time.
Durability:
After the transaction completes, the transaction's operation on the database is persisted in the database and will not be rolled back.
The ACID nature of a transaction is implemented by a relational database management system (RDBMS). Database management systems use logs to ensure atomicity, consistency, and persistence of transactions. The log records the updates made by the transaction to the database. If an error occurs during the execution of a transaction, the log can be used to undo the updates made by the transaction to the database and return the database to the initial state before the transaction was executed.
Database management system adopts lock mechanism to realize transaction isolation. When multiple transactions update the same data in the database at the same time, only the transaction holding the lock is allowed to update the data, and the other transactions must wait until the previous transaction releases the lock.
There are two main ways to implement ACID: the first is Write ahead logging, which is the journaling method. The second is Shadow paging.
CAP theorem:
CAP theorem, also known as CAP principle, refers to a distributed system, Consistency (consistency), Availability (availability), Partition tolerance (partition tolerance), the three can not be obtained. CAP theorem clarifies the limitations of what distributed systems can achieve. Many distributed systems in the Internet are designed to satisfy availability and partition tolerance first.
CAP principle is the cornerstone of NoSQL database and the theoretical basis of NoSQL.
Consistency:
That is, data consistency, simply put, is that the data is copied to N machines, if there is an update, the data of N machines is updated together.
Availability:
Each request receives a response, whether successful or unsuccessful.
Partition tolerance:
In large-scale distributed data systems, network partitioning, i.e., the inability of machines between partitions to communicate on the network, is inevitable, so the system should be able to continue to work in this case.
The above is all the content of this article,"Example analysis of ACID theory and CAP theory in database", thank you for reading! I believe that everyone has a certain understanding, hope to share the content to help everyone, if you still want to learn more knowledge, welcome to pay attention to the industry information channel!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.