数据库系统原理(英文)-8-11.ppt
上传人:qw****27 上传时间:2024-09-12 格式:PPT 页数:45 大小:264KB 金币:15 举报 版权申诉
预览加载中,请您耐心等待几秒...

数据库系统原理(英文)-8-11.ppt

数据库系统原理(英文)-8-11.ppt

预览

免费试读已结束,剩余 35 页请下载文档后查看

15 金币

下载此文档

如果您无法下载资料,请参考说明:

1、部分资料下载需要金币,请确保您的账户上有足够的金币

2、已购买过的文档,再次下载不重复扣费

3、资料包下载后请先用软件解压,在使用对应软件打开

PART2Chapter8ApplicationDesignandDevelopmentFig.1.0.6DataabstractionandSchema用户A1Specificationofuserrequirements(需求分析说明书)Fig.6.0.3DBAS生命周期模型Casestudyusedinthischapter§8.6Trigger(触发器)8.6Trigger(cont.)Supposethat,insteadofallowingnegativeaccountbalances,thebankdealswithoverdrafts(透支)byfollowingactionssettingtheaccountbalancetozerocreatingaloanintheamountoftheoverdraftgivingthisloanaloannumberidenticaltotheaccountnumberoftheoverdrawnaccountTriggeroverdraft-triggerinFig.8.8thetriggeringeventisupdateonbalancetheconditionforexecutingthetriggerisanmodificationtotheaccountrelationthatresultsinanegativebalancevaluecreatetriggeroverdraft-triggerafterupdateonaccount---eventreferencingnewrowasnrowforeachrowwhennrow.balance<0-------conditionbeginatomic-------actioninsertintoborrower(selectcustomer-name,account-numberfromdepositorwherenrow.account-number=depositor.account-number);insertintoloanvalues(nrow.account-number,nrow.branch-name,–nrow.balance);updateaccountsetbalance=0whereaccount.account-number=nrow.account-numberendGSM网络配置数据库中,利用触发器实现向小区(cell)中新增频点,约束:每个小区最多只有8个频点计算性能指标“BSC切换成功率”,原理:每当发生一次BSC切换时,根据本次切换是否成功重新计算“切换成功率”createtriggeroverfreonCell_TCHforinsert/*事件event*/asIFexists(selectcellid,count(TCHno)asnum/*条件condition*/fromCell_TCHgroupbycellidhavingcount(TCHno)>8)BegintransactiondeletefromCell_TCHwhereCell_TCH.TCHno=(selectmin(TCHno)asminfrenofromCell_TCHgroupbycellidhavingcount(TCHno)>8)print'插入TCH频点多于8个,频点号最小的已经被删除!'Endasinglestatementcanthenbeusedtocarryoutmultipleactionsonthebasisofthetemporary/transitiontables,andthusismoreefficientwhendealingwithSQLstatementsthatupdatealargenumberofrowsAlthoughtriggercanbeusedtomaintainDBSintegrity,itmaybeinefficientinsomecasesifeventsoccursfrequently,actionswillbefrequentlytakentoaccessonDBSomemoreefficientmechanisms,suchasmaterializedviews,insteadoftriggers,areusedtomaintaindatainDBFormoredetails,refertoAppendixAWhenNotToUseTriggers§8.7AuthorizationinSQLFig.SecurityControlArc