欢迎来到天天文库
浏览记录
ID:51622833
大小:2.39 MB
页数:53页
时间:2020-03-26
《数据库系统概念全套配套课件PPT ch14.ppt》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、Chapter14:TransactionsChapter14:TransactionsTransactionConceptTransactionStateConcurrentExecutionsSerializabilityRecoverabilityImplementationofIsolationTransactionDefinitioninSQLTestingforSerializability.TransactionConceptAtransactionisaunitofprogramexecutionthataccessesandpossiblyupdat
2、esvariousdataitems.E.g.transactiontotransfer$50fromaccountAtoaccountB:1.read(A)2.A:=A–503.write(A)4.read(B)5.B:=B+506.write(B)Twomainissuestodealwith:Failuresofvariouskinds,suchashardwarefailuresandsystemcrashesConcurrentexecutionofmultipletransactionsExampleofFundTransferTransactiontot
3、ransfer$50fromaccountAtoaccountB:1.read(A)2.A:=A–503.write(A)4.read(B)5.B:=B+506.write(B)Atomicityrequirementifthetransactionfailsafterstep3andbeforestep6,moneywillbe“lost”leadingtoaninconsistentdatabasestateFailurecouldbeduetosoftwareorhardwarethesystemshouldensurethatupdatesofapartial
4、lyexecutedtransactionarenotreflectedinthedatabaseDurabilityrequirement—oncetheuserhasbeennotifiedthatthetransactionhascompleted(i.e.,thetransferofthe$50hastakenplace),theupdatestothedatabasebythetransactionmustpersisteveniftherearesoftwareorhardwarefailures.ExampleofFundTransfer(Cont.)T
5、ransactiontotransfer$50fromaccountAtoaccountB:1.read(A)2.A:=A–503.write(A)4.read(B)5.B:=B+506.write(B)Consistencyrequirementinaboveexample:thesumofAandBisunchangedbytheexecutionofthetransactionIngeneral,consistencyrequirementsincludeExplicitlyspecifiedintegrityconstraintssuchasprimaryke
6、ysandforeignkeysImplicitintegrityconstraintse.g.sumofbalancesofallaccounts,minussumofloanamountsmustequalvalueofcash-in-handAtransactionmustseeaconsistentdatabase.Duringtransactionexecutionthedatabasemaybetemporarilyinconsistent.Whenthetransactioncompletessuccessfullythedatabasemustbeco
7、nsistentErroneoustransactionlogiccanleadtoinconsistencyExampleofFundTransfer(Cont.)Isolationrequirement—ifbetweensteps3and6,anothertransactionT2isallowedtoaccessthepartiallyupdateddatabase,itwillseeaninconsistentdatabase(thesumA+Bwillbelessthanitshouldbe).T1T21.read(A)2.A:=A–50
此文档下载收益归作者所有