数据库事物ACID特性和分布式系统CAP理论

ACID特性和分布式系统CAP理论


事物的介绍和认识

事务通常指的是数据库事务,不要把它太概念化,就是一些列操作要么都执行要么都不执行,把这些操作封装在一个不可分割的单元体里这么理解就可以。

//备注最常见用来举例说明事务的例子应该就是银行账户转账的场景了吧。

在mysql中只有部分数据库引擎才支持事务,推荐尽量都使用支持事务的引擎,不然给后面开发带来很多麻烦
(切身体会,曾经在一家公司做支付系统和订单业务太痛苦了,公司每天流水有几百万搞得真是提心吊胆啊)

ACID的介绍和理解

数据库事务所应具备的四个特性:

1、Atomicity(原子性)
2、Consistency(一致性)
3、Isolation(隔离性)
4、Durability(持久性)

备注:这里的数据库事务通常指的是关系型数据库的事务。

原子性

An atomic transaction is an indivisible and irreducible series 
of database operations such that either all occur, or nothing occurs.


原子性事务是一个不可分割和一系列不可约数据库操作,要么全部执行要么就都不执行。
原子性事务:首先我们应该从表面意思去理解原子,原子是世界上最小不可分割单
位体,原子性事务就是在事务的基础上加上原子的特性。

Example

Example of atomic transaction is a monetary transfer from bank account A to account B. It consists of two operations, 
withdrawing the money from account A and saving it to account B. Performing these operations in an atomic transaction ensures 
that the database remains in a consistent state, that is, money is not lost nor created if either of those two operations fail.


Atomicity requires that each transaction be "all or nothing": if one part of the transaction fails, then the entire transaction 
fails, and the database state is left unchanged.

一致性

Consistency in database systems refers to the requirement that any given database transaction must change affected 
data only in allowed ways. Any data written to the database must be valid according to all defined rules, 
including constraint
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值