版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
PART2RELATIONALDATABASES第一页,编辑于星期五:十二点三十七分。April20091*Chapter8
ApplicationDesignandDevelopment第二页,编辑于星期五:十二点三十七分。April20092*CasestudyusedinthischapterreturnFig.8.0Schemaofbankingenterprise第三页,编辑于星期五:十二点三十七分。April20093*
§8.6Trigger(触发器)TriggerastatementthatisexecutedautomaticallybyDBMSasasideeffectofamodificationtothedatabaseAsanintegritycontrolmechanism,TriggerisintroducedtoSQL1999standard,butsupportedevenearlierusingnon-standardsyntaxbymostdatabases第四页,编辑于星期五:十二点三十七分。April20094*
8.6Trigger(cont.)Triggerisanevent-condition-actionmodelbasedintegritydefinition,checking,remedymechanismspecifywhateventscausethetriggertobeexecuted(e.g.insert,delete,update),andunderwhichconditionsthetriggerexecutionwillproceedintegrityconstraintscheckingspecifytheactionstobetakenwhenthetriggerexecutesifconstraintsisviolated,remedyactionsaretaken第五页,编辑于星期五:十二点三十七分。April20095*Supposethat,insteadofallowingnegativeaccountbalances,thebankdealswithoverdrafts(透支)byfollowingactionssettingtheaccountbalancetozerocreatingaloanintheamountoftheoverdraftgivingthisloanaloannumberidenticaltotheaccountnumberoftheoverdrawnaccountTriggeroverdraft-triggerthetriggeringeventisupdateonbalancethecondition
forexecutingthetriggerisanmodificationtotheaccountrelationthatresultsinanegative
balancevalueExampleOne第六页,编辑于星期五:十二点三十七分。April20096*triggeractionsareinsertonborrower,loanrelations,andupdateonaccountrelationExampleOne(cont.)第七页,编辑于星期五:十二点三十七分。April20097*createtriggeroverdraft-triggerafter
updateonaccount---event
referencingnewrowasnrowforeachrow
whennrow.balance<0
-------condition
beginatomic
-------action
insertinto
borrower
(selectcustomer-name,account-number
fromdepositor
wherenrow.account-number=
depositor.account-number);
insertinto
loanvalues
(nrow.account-number,nrow.branch-name,
–nrow.balance);
update
accountsetbalance=0
whereaccount.account-number=nrow.account-number
end
Overdraft-trigger第八页,编辑于星期五:十二点三十七分。April20098*GSM网络配置数据库中,利用触发器实现向小区(cell)中新增频点,约束:每个小区最多只有8个频点计算性能指标“BSC切换成功率”,原理:每当发生一次BSC切换时,根据本次切换是否成功重新计算“切换成功率”ExampleTwo第九页,编辑于星期五:十二点三十七分。April20099*createtriggeroverfreonCell_TCHforinsert/*事件event*/asIFexists(selectcellid,count(TCHno)asnum
/*条件condition*/ fromCell_TCH groupbycellid havingcount(TCHno)>8)BegintransactiondeletefromCell_TCHwhereCell_TCH.TCHno=(selectmin(TCHno)asminfreno fromCell_TCH groupbycellid havingcount(TCHno)>8)print'插入TCH频点多于8个,频点号最小的已经被删除!'EndFig.触发器“新增小区频点”动作第十页,编辑于星期五:十二点三十七分。April200910*Theeventsandactionsintriggercantakemanyformsthetriggereventscanalsobeinsertordelete,insteadofupdatetriggersonupdatecanberestrictedtospecificattributese.g.createtriggeroverdraft-triggerafterupdateofbalance
onaccounttriggerscanbeactivatedbeforeorafteranevent,whichcanserveasextraconstraintsvaluesofattributesbeforeandafteranupdatecanbereferencedreferencingoldrowas:fordeletesandupdatesreferencingnewrowas:forinsertsandupdates
8.6Trigger(cont.)第十一页,编辑于星期五:十二点三十七分。April200911*e.g.inFig.8.8,theclausereferencingnewrowasnrowcreateavariablenrowtostorethenewvaluesoftheupdatedtuplesinaccountinsteadofexecutingaseparateactionforeachaffectedrow,asingleactioncanbeexecutedfortheentireSQLstatementthatcausedtheinsert/delete/update,i.e.forallrowsaffectedbyasingletransactionuseforeachstatementinsteadofforeachrowusereferencingoldtableorreferencingnewtabletorefertotemporary/transitiontablescontainingtheaffectedrows
8.6Trigger(cont.)第十二页,编辑于星期五:十二点三十七分。April200912*asinglestatementcanthenbeusedtocarryoutmultipleactionsonthebasisofthetemporary/transitiontables,andthusismoreefficientwhendealingwithSQLstatementsthatupdatealargenumberofrowsAlthoughtriggercanbeusedtomaintainDBSintegrity,itmaybeinefficientinsomecasesifeventsoccursfrequently,actionswillbefrequentlytakentoaccessonDBSomemoreefficientmechanisms,suchasmaterializedviews,insteadoftriggers,areusedtomaintaindatainDBFormoredetails,refertoAppendixAWhenNotToUseTriggers
8.6Trigger(cont.)第十三页,编辑于星期五:十二点三十七分。April200913*§8.7AuthorizationinSQL第十四页,编辑于星期五:十二点三十七分。April200914*UserIdentifier(口令)Authorization(inanarrowsense):privilegedefinition(授权)privilegecheckingencryptiontechniquesUserDBMSNetwork&OperatingsystemDBphysicalstorage第十五页,编辑于星期五:十二点三十七分。April200915*第十六页,编辑于星期五:十二点三十七分。April200916*第十七页,编辑于星期五:十二点三十七分。April200917*DBMSprovidesauthorizationondataaccesstoDBattwolevelsdata(attributes,tuples,tables)levelsschemalevelsAuthorizationondatalevelsread,insert,update,deleteAuthorizationonschemalevelsindex,creation,alteration,dropAuthorizationinDBS第十八页,编辑于星期五:十二点三十七分。April200918*objects
operatingprivilegesattributeSELECT,INSERT,UPDATE,DELETE,ALLPRIVILEGESviewSELECT,INSERT,UPDATE,DELETE,ALLPRIVILEGEStableSELECT,INSERT,UPDATE,DELETE,ALTER,
INDEX,
Create
ALLPRIVILEGESdatabaseCREATETABTable8.0.1PrivilegesinSQL
第十九页,编辑于星期五:十二点三十七分。April200919*GrantstatementinSQLgivesusersprivilegesonDBaccessUsersgrantedsomeformofauthorizationmaybeallowedtopassontheauthorizationtootherusers§8.7.1GrantingofPrivileges
(权限授予)第二十页,编辑于星期五:十二点三十七分。April200920*Thepassageofauthorizationfromoneusertoanotherisrepresentedbyanauthorizationgraphthenodesofthisgrapharetheusers,therootofthegraphisthedatabaseadministrator(DBA)e.g.graphforupdateauthorizationonloanU1U4U2U5U3DBA
anedgeUi
UjindicatesthatuserUihasgranted
updateauthorizationonloantoUj.8.7.1GrantingofPrivilegesinSQL(cont.)第二十一页,编辑于星期五:十二点三十七分。April200921*NotealledgesinanauthorizationgraphmustbethepartofsomepathoriginatingwiththedatabaseadministratorDBAcanrevokeprivilegesusershaveobtained.E.g.InFig.8.11,ifDBArevokesgrantfromU1grantmustberevokedfromU4sinceU1nolongerhasauthorizationgrantmustnotberevokedfromU5sinceU5hasanotherauthorizationpathfromDBAthroughU28.7.1GrantingofPrivileges(cont.)第二十二页,编辑于星期五:十二点三十七分。April200922*Thegrantstatementisusedtoconferauthorization
grant<privilegelist>
on<relationnameorviewname>to<userlist><userlist>isauser-idpublic,whichallowsallvaliduserstheprivilegegrantedarole(moreonthislater)Thegrantoroftheprivilegemustalreadyholdtheprivilegeonthespecifieditem(orbethedatabaseadministrator)8.7.2AuthorizationinSQL第二十三页,编辑于星期五:十二点三十七分。April200923*E.g.grantusersU1,U2,andU3
selectauthorizationonthebranch
relation
grantselectonbranch
toU1,U2,U38.7.2AuthorizationinSQL(cont.)第二十四页,编辑于星期五:十二点三十七分。April200924*Tosimplifytheauthorizationtoeachusersinthesystem,theconceptofroleisintroducedrole:usergroup,usersinarolehavethesamecommonprivilegesonDBPrivilegescanbegrantedtoorrevokedfromroles,justlikeuserausercanbedenotedasarole,andthenbegrantedtheprivilegesoftherolethenumberofrolesinthesystemislessthanthenumberofusers§8.7.3Roles第二十五页,编辑于星期五:十二点三十七分。April200925*SQL:1999supportsrolescreateroleteller
createrolemanagergrantselectonaccounttotellergrantupdate(balance)onaccounttotellerRolescanbeassignedtousers
grant
tellertojohn
grantmanagertomarygranttellertomanager8.7.3Roles(cont.)第二十六页,编辑于星期五:十二点三十七分。April200926*Therevokestatementisusedtorevokeauthorization.revoke<privilegelist>on<relationnameorviewname>from<userlist>[restrict|cascade]8.7.4RevokingofPrivilegesE.g.revokeselectonbranch
fromU1,U2,U3
cascadeRevocationofaprivilegefromausermaycauseotherusersalsotolosethatprivilege;referredtoascascadingoftherevoke第二十七页,编辑于星期五:十二点三十七分。April200927*§8.7.5AuthorizationandViews第二十八页,编辑于星期五:十二点三十七分。April200928*E.g.supposeabankclerkneedstoknowthenamesofthecustomersofeachbranch,butisnotauthorizedtoseespecificloaninformationapproach:denydirectaccesstothe
loan
relation,butgrantaccesstotheviewcust-loan,whichconsistsonlyofthenamesofcustomersandthebranchesatwhichtheyhavealoan createviewcust-loanas
selectbranch-name,customer-name
fromborrower,loan
whereborrower.loan-number=loan.loan-number8.7.5AuthorizationandViews(cont.)第二十九页,编辑于星期五:十二点三十七分。April200929*8.7.5AuthorizationandViews(cont.)第三十页,编辑于星期五:十二点三十七分。April200930*Creationofviewdoesnotrequireresourcesauthorization(creatingnewrelations)sincenorealrelationisbeingcreatedThecreatorofaviewgetsonlythoseprivilegesthatprovidenoadditionalauthorizationbeyondthathealreadyhade.g.ifcreatorofviewcust-loanhadonlyselect,insert,anddeleteauthorizationonborrowerandloan,hegetsonlyselect
,insert,anddeleteauthorizationoncust-loan8.7.5AuthorizationandViews(cont.)
borrower
loan
cust-loan
userprivilege:select,insert,deleteselect,insert,delete第三十一页,编辑于星期五:十二点三十七分。April200931*Audittrail(审计追踪)alog(日志)ofallchanges(inserts/deletes/updates)tothedatabasealongwithinformationsuchaswhichuserperformedthechange,andwhenthechangewasperformedAnotherDefinitionAudittrailofinMicrosoftPressComputingDictionaryinreferencetocomputing,ameansoftracingallactivitiesaffectingapieceofinformation,suchasadatarecord,fromthetimeitisenteredintoasystemtothetimeitisremovedanaudittrailmakeitpossibletodocument,forexample,whomadeachangetoaparticularrecordandwhen§8.7.7AuditTrail第三十二页,编辑于星期五:十二点三十七分。April200932*
T1:begin-transactionread(A)A:=A-50write(A)read(B)B:=B+50write(B)commit
T2:begin-transactionread(A)temp:=A*0.1A:=A-tempwrite(A)read(B)B:=B+tempwrite(B)abortFig.ConcurrentexecutingofT1andT2
log<T1start><T2start><T1,A,1000,950><T2,A,950,855><T1,B,2000,2050><T1,commit><T2,B,2050,2145><T2abort>Initially,A=1000,B=2000第三十三页,编辑于星期五:十二点三十七分。April200933*Audittrailisusedtotrackerroneous/fraudulentupdatesAsshowninChapter17,onthebasisoflog,DBSrecoveryisimplementedAudittrailcanbeimplementedusingtriggers,butmanydatabasesystemsprovidedirectsupport8.7.7AuditTrail(cont.)第三十四页,编辑于星期五:十二点三十七分。April200934*8.8.1EncryptionTechniquesDatamaybeencrypted
whendatabaseauthorizationprovisionsdonotoffersufficientprotection
第三十五页,编辑于星期五:十二点三十七分。April200935*
Digital
signaturesarealsousedtoverifyauthenticityofdata第三十六页,编辑于星期五:十二点三十七分。April200936*Appe
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 企业合规管理的操作指南
- 安全环保目标达成承诺书范文5篇
- 介孔二氧化硅纳米粒的药物递送研究报告
- 社区绿化带保护维护预案
- 食品饮料加工新技术研究
- 企业服务承诺保证承诺书范文3篇
- 酒店餐饮服务卫生管理规范方案
- 财务管理问题分析处理手册
- 食品卫生安全与检验规范手册
- 小学学习动机“2025”说课稿
- 假发行业营销方案
- 地源热泵打井协议书
- 口腔器械清洗消毒培训
- 2025年全国社区工作者招聘考试公共基础知识真题及答案
- 机械制图的基本知识与技能教学设计-2025-2026学年中职专业课-汽车机械基础-汽车运用与维修-交通运输大类
- PADI潜水OW理论知识课件
- 部编人教版一年级语文下册期末重点知识点复习
- 小儿脑瘫病例书写范文
- 健身房设计方案
- 车队车辆防汛安全培训课件
- 企业税务规划与合规管理模板
评论
0/150
提交评论