数据库系统 事务管理_数据库管理系统中的事务

数据库系统 事务管理

交易 (Transaction)

A transaction is a logical unit of database processing that includes one or more database access operations such as an insertion, deletion, modification, and retrieval. Instructions are always atomic in nature i.e. either an instruction execute completely or it does not execute at all.

事务是数据库处理的逻辑单元,包括一个或多个数据库访问操作,例如插入,删除,修改和检索 。 指令本质上总是原子的,即,一条指令完全执行或根本不执行。

But it is possible to have partially executed programs which means some instructions are executed but some are not. According to the user either a work is done or not done therefore a transaction is that of instructions which perform a logical unit of work.

但是可能会有部分执行的程序,这意味着执行了一些指令,但没有执行。 根据用户,一项工作已经完成或未完成,因此事务是执行逻辑工作单元的指令的事务。

Example:

例:

Transaction T transfer 100 units of account A to B.

事务T将帐户A的100个单位转移到B。

    Read(A)
    A= A – 100
    Write(A)

Read(B) → If transaction fails here, then system will be inconsistent as 100 units debited from Account A but not added to account B.

读取(B)→如果此处交易失败,则系统将不一致,因为从帐户A借记了100个单位,但未将其添加到帐户B中。

    B = B + 100
    Write(B)

To remove this partially executed problem, we increase the level of atomicity and bundle all instruction of a logical operation into a unit called transaction.

为了消除此部分执行的问题,我们提高了原子性,并将逻辑操作的所有指令捆绑到一个称为事务的单元中。

Transaction access data using two operations:

事务访问数据使用两种操作:

1) Read(X): It transfers the data item X from the database to a local buffer belonging to the transaction that executed the read operation.

1)Read(X) :它将数据项X从数据库传输到属于执行读取操作的事务的本地缓冲区。

2) Write(X): It transfers the data item X from the local buffer of the transaction that executed the write back to the database.

2)Write(X) :它将数据项X从执行写回操作的事务的本地缓冲区传输到数据库。

If we want that our database should be consistent than we understand that transaction which operates on a database must be satisfied "acid property".

如果我们希望我们的数据库保持一致,那么我们就必须理解,对数据库进行的事务必须满足“酸性属性”

交易性质 (Properties of Transaction)

These are the important properties of transaction that a DBMS must ensure to maintain the database. These properties are called "ACID property".

这些是DBMS必须维护的重要交易属性。 这些属性称为“ ACID属性”

  1. Atomicity

    原子性

    "A" stands for atomicity it states that either all the instructions participating in a transaction will execute or none. Atomicity is guaranteed by transaction management component.

    “ A”表示原子性,它表示参与交易的所有指令都将执行或不执行。 事务管理组件可确保原子性。

  2. Consistency

    一致性

    "C" stands for consistency it states that if a database is consistent before the execution of a transaction that if must remains consistent after execution of a transaction.

    “ C”表示一致性,它表示如果数据库在执行事务之前是一致的,则在执行事务之后必须保持一致。

    Note: If atomicity, isolation, durability holds well then consistency holds well automatically.

    注意:如果原子性,隔离性,持久性保持良好,则一致性自动保持良好。

  3. Isolation

    隔离

    Isolation means if a transaction run isolately or concurrently with other transaction then the result must be same. Concurrency control component takes cares of isolation.

    隔离意味着,如果一个事务与其他事务独立运行或并发运行,那么结果必须相同。 并发控制组件负责隔离。

  4. Durability

    耐用性

    Durability means that the work done by a successful transaction must remain in the system. Even in case of any hardware or software failure.

    持久性意味着成功事务完成的工作必须保留在系统中。 即使出现任何硬件或软件故障。

    Note: Recovery management component takes care of durability.

    注意:恢复管理组件会考虑持久性。

Recovery from failures means that the database is restored to the most consistent state just before the time of failure. To do this the system must keep information about the changes that were applied to the data item by the various transactions. This information is kept system log.

从故障中恢复意味着在故障发生之前将数据库恢复到最一致的状态。 为此,系统必须保留有关各种事务对数据项应用的更改的信息。 此信息保存在系统日志中。

These properties are responsible for one of the components of DMBS,

这些属性是DMBS的组成部分之一,

PropertyRecovery Management Component
1. AtomicityRecovery manager
2. ConsistencyUser programmer
3. IsolationConcurrency control system
4. DurabilityRecovery manager
属性 恢复管理组件
1.原子性 恢复管理器
2.一致性 用户程序员
3.隔离 并发控制系统
4.耐久性 恢复管理器

交易状态 (Transaction states)

A transaction moves from one state to the other as it entries the system to be executed. A transaction must be in one of the following states:

事务在进入要执行的系统时会从一种状态转移到另一种状态。 事务必须处于以下状态之一:

  1. Active

    活性

    A transaction is said to an active state if the instruction is executing.

    如果指令正在执行,则将事务称为活动状态。

  2. Partially committed

    部分承诺

    Partially committed state means that all the instructions are executed but changes are temporary and not updated in the database.

    部分提交状态表示所有指令均已执行,但更改是临时的,不会在数据库中更新。

  3. Committed

    承诺的

    When changes are made permanent than it is said to be committed.

    如果更改是永久性的,则将其称为永久更改。

  4. Failed

    失败的

    If any problem is detected either during active state or partially committed state than transaction enters in a failed state.

    如果在活动状态或部分提交状态期间检测到任何问题,则事务将进入失败状态。

  5. Aborted

    中止

    Aborted state means all the changes that were in the local buffer are deleted. Either we are committed or aborted database is consistent.

    中止状态意味着删除本地缓冲区中的所有更改。 我们提交的数据库或中止的数据库都是一致的。

Transaction in Database Management System

翻译自: https://www.includehelp.com/dbms/transaction-in-database-management-system.aspx

数据库系统 事务管理

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值