Home >Common Problem >What are the ACID properties of relational database system transactions?
ACID characteristics of relational database system transactions: 1. Atomicity; all operations in the transaction are either completed or none. 2. Consistency; the database must always be in a consistent state. 3. Independence; concurrent transactions will not affect each other. 4. Persistence; once a transaction is committed, the modifications it makes will be permanently saved in the database.
The operating environment of this tutorial: Windows 7 system, mysql version 5.8, Dell G3 computer.
(Recommended tutorial: mysql video tutorial)
Transactions are the core of relational databases. The reason why relational databases have flourished in the past few decades is because Its support for transactions is inseparable. But as the saying goes, success is as bad as failure. With the explosive growth of data volume, especially the booming development of big data in recent years, relational database transactions have become the performance bottleneck of Internet applications. NoSQL has abandoned relationships. Certain attributes of database transactions make their performance many times that of relational databases for certain types of special applications.
Let’s first talk about what a transaction is. A transaction is a transaction in English, which is very similar to a transaction in the real world. It has the following four characteristics:
1. A (Atomicity) Atomicity
Atomicity is easy to understand. That is to say, all operations in the transaction are either completed or none. The condition for the success of the transaction is that all operations in the transaction are successful. , as long as one operation fails, the entire transaction fails and needs to be rolled back.
For example, by bank transfer, transferring 100 yuan from account A to account B is divided into two steps: 1) Withdraw 100 yuan from account A; 2) Deposit 100 yuan into account B. These two steps are either completed together or not completed together. If only the first step is completed and the second step fails, the money will be 100 yuan less for no reason.
2. C (Consistency) Consistency
Consistency is also easier to understand, which means that the database must always be in a consistent state 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 a b=10 is still satisfied 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 to be accessed by a transaction is currently Modified by another transaction, as long as the other transaction is not committed, the data it accesses will not be affected by the uncommitted transaction.
For example, there is a transaction that transfers 100 yuan from account A to account B. If the transaction is not completed yet, if B checks his account at this time, he will not see the newly added 100 yuan. Yuan.
4. D (Durability) Durability
Durability means that once a transaction is committed, the modifications it makes will be permanently saved in the database, even if It will not be lost even if there is a downtime.
Let’s take the above example again. If the transfer is successful and the database is down at this time, after restarting, you can still see the results of the successful transfer.
For more programming-related knowledge, please visit: Programming Teaching! !
The above is the detailed content of What are the ACID properties of relational database system transactions?. For more information, please follow other related articles on the PHP Chinese website!