题目详情

某超市销售系统的部分关系模式如下

商品表: Commodity(Ccode, Cname, price,qty),其中属性含义分别为:商品编号、商品名称、价格、库存量,有专门的事务保证库存量足够大,销售时无需检测。

销售表: Sale(Sno,Ccode, amount, Stime),其中属性含义分别为:销售编号,商品编号、数量、时间。

其销售业务规则如下:顾客在超市挑选好商品后,带商品到结算处结算付款,结算处有多名结算员使用多台机器进行结算。结算员负责扫顾客购买商品的条码和数量,由系统后台结算程序计算出顾客购买商品的总金额,修改商品表的商品库存量,并将销售信息写入销售表。

请根据上述描述,回答以下问题。

【问题1】(3分)

假设有两个顾客同时购买同一条码的商品,结算事务修改该商品的库存量(记为数据项X)部分的调度如图5-1所示。

中级数据库系统工程师,历年真题,2018年上半年《数据库系统工程师》案例分析真题

图5-1 部分结算事务调度图

如果购买前X的初值为10,则上述调度执行完成后,X的值是多少?属于哪一类不一致性?

【问题2】(6分)

引入独占锁指令 Xlock(  )和解锁指令 Unlock(  ),对【问题1】中的调度进行重写,要求满足两段锁协议,且事务T1、T2首条指令的相对请求时间与【问题1】中的相同。

【问题3】(6分)

下面是用SQL实现的结算程序,请补全空缺处的代码。

要求在保证销售信息不丢失的前提下,达到最大的系统并发度。

CREATE PROCEDURE buy(IN: CommNo VARCHAR(20), IN: AmountBuy INT)

BEGIN

//输入合法性验证

if(: AmountBuy<1) return -1;

SET TRANSACTION ISOLATION LEVEL (a) ;

BEGIN TRANSACTION;

//插入销售记录

INSERT INTO Sale

VALUES(getGUID(  ),: CommNo, :AmountBuy, getDATETIME(  ));

//函数 getGUID(  ):获取唯一值

//函数 getDATETIME(  ):获取当前系统日期时间

if error ∥error是由DBMS提供的上一句SQL的执行状态

BEGN

ROLLBACK; return -2;

END

//修改库存数量

UPDATE Commodity

SET qty= (b)

WHERE Ccode=: CommNo;

if error

BEGIN

ROLLBACK; return -3;

END

(c)

END

正确答案及解析

正确答案
解析

【问题1】

X的值为8。属于丢失更新引起的不一致性。

【问题2】

中级数据库系统工程师,历年真题,2018年上半年《数据库系统工程师》案例分析真题

【问题3】

(a) read uncommitted

(b) qty - :AmountBuy

(c) commit;

return 0;

包含此试题的试卷

你可能感兴趣的试题

单选题

Advancements in ( )have contributed to the growth of the automotive industry through the creation and evolution of self-driving vehicles.

  • A.Artificial Intelligence
  • B.Cloud Computing
  • C.Internet of Things
  • D.Big Data
查看答案
单选题

In project human resource management , ( )is not a source of power for the project manager.

  • A.referent power
  • B.expert power
  • C.reward power
  • D.audit power
查看答案
单选题

At the project establishment stage , the feasibility study mainly includes techinical feasibility analysis , ( ), operation environment feasibility analysis and other aspects of feasibility analysis.

  • A.detail feasibility analysis
  • B.opportunity analysis
  • C.economic feasibility analysis
  • D.risk analysis
查看答案
单选题

( )is a grid that shows the project resources assigned to each work package.

  • A.Stakeholder engagement assessment matrix
  • B.Requirements traceability matrix
  • C.Probability and impact matrix
  • D.Responsibility assignment matrix
查看答案
单选题

Xinhua News Agency reported in January 2022,Chian will further promote the developmet of a digital economy during the 14th Five-Year Plan eriod(2021-2025). The plan also emphasized industrial ( )transformation.

  • A.digital
  • B.networking
  • C.intelligentize
  • D.informatization
查看答案

相关题库更多 +