
吉林大学软件学院《数据库原理》期末试题A卷(答案)参考.pdf
4页2009-2010学年第 2 学期2007 级数据库系统原理考试题(A) 考试时间: 2010 年 6 月班级:学号:姓名:请将答案写在答题纸上,写明题号,不必抄题,字迹工整、清晰;请在答题纸和试题纸上都写上你的班级,学号和姓名,交卷时请将试题纸、答题纸和草纸一并交上来一、20 分用英文解释下列名词:1. Instance :the actual content of the database at a particular point in time 2. Relationship: A relationship is an association among several entities 3. Weak entity set :An entity set that does not have a primary key is referred to as a weak entity set . 4. Transactions : A transaction is a unit of program execution that accesses and possibly updates various data item. 5. Foreign key:A relation schema may have an attribute that corresponds to the primary key of another relation. The attribute is called a foreign key. 6. RAID:Redundant Arrays of Independent Disks ,disk organization techniques that manage a large numbers of disks, providing a view of a single disk7. Dense Clustering index:Index record appears for every search-key value in the file. 8. Query Optimization:Amongst all equivalent evaluation plans choose the one with lowest cost. 9. Schedule :a sequences of instructions that specify the chronological order in which instructions of concurrent transactions are executed 10. Conflict equivalent:If a schedule S can be transformed into a schedule Sby a series of swaps of non-conflicting instructions, we say that S and Sare conflict equivalent .二、20 分以下是某健身俱乐部的会员管理数据库,其保存的信息有:顾客成为会员后,会建立会员档案(members) ,包括会员编号Cid,姓名Cname ,性别 Csex,年龄 Cage ,联系 Phone ,入会时间 Cdate 根据会员的一次性缴费情况,分成初级会员、中级会员、高级会员、VIP 会员等不同的等级 type,可以享受不同的折扣discount;由于俱乐部不定期举办优惠活动,因此相同级别的会员可能会有不同的折扣;俱乐部有若干健身教练为会员提供服务,健身教练(adviser) 的信息包括:编号 Ano,姓名 Aname ,性别 Asex, Atel;健身教练是分等级的,健身教练的等级 Alevel 随着其指导人数和工作时间的增长而增长;每个会员每次健身都配有一个专职的健身教练;健身教练的工资按日薪发放,包括分两部分:一部分是根据其级别发放的基本工资 salary ,相同级别的教练工资相同;另一部分是根据每天为客户服务的次数确定的奖金 awards,不同级别的教练,其每人次的奖金额度也不同。
1. 画出上述关系的 E-R 模型15 分 2. 将 E-R 模型转换为符合 3NF 规范的关系模型 5 分 Members = (cid, cname, cage, csex, phone, cdate, type, discount) Adviser = (ano, aname, asex, atel, level) Alevel = (Level, salary, awards) MA = (Cid, Ano, MAtime) 三、15 分根据第二题的中定义的关系模式,用关系代数表达式完成下列查询1. 查询年龄大于 30岁的女会员的姓名和入会时间cname,cdate(cage 40 & csex= 女(members ) )2. 查询 2010年 5 月 1 日来俱乐部健身的会员及其指导教练的姓名cname,aname(MAtimee =20100501(members MA adviser) )3. 查询所有 1 号教练指导过,但是2 号教练没有指导过的会员的姓名cname(ano = 1(memebers MA) )- cname(ano = 2(memebers MA) )4. 查询被所有男教练都指导过的会员的姓名cname ,ano(members MA) )ano(asex = 男(adviser ) )5. 查询享受最大折扣的会员的名字和用户等级cname ,type(g max(discoun t)(members ) )四、20 分根据第二题的中定义的关系模式,用SQL 完成下列操作。
1. 查询俱乐部所有的教练的名字和级别,并按照教练级别进行降序排列,级别相同的按姓名的升序排列3 分 Select aname ,level 2 2 2 2 2 MA MembersadviserCname Cid Csex Cdate Aname Ano Asex Atel Cage Phone MAtime discountType Tname 教练级别ALevel Level salary awards 2 2 1 From adviser Order by level desc ,aname asc 2. 查询陈宇教练指导过的年龄大于40 岁的会员的名字 3 分 Select cname From memebers ,MA ,adviser Where members.cid=MA.cid and MA.ano=adviser.ano and cage40 and aname= 陈宇3. 查询所有 1 级教练指导过的会员的名字3 分 Select cname From memebers ,MA Where members.cid=MA.cid and MA.ano in ( select ano from adviser where level= 1 ) 4. 查询 2010年 5 月 1 日指导会员次数超过5 人次的教练的名字。
3 分 Select aname From MA,adviser Where MA.ano=adviser.ano and MAtime= 20100501Group by MA.ano Having count(*)5 5. 创建一个包含陈宇教练每天日工资的视图v_chenyu4 分 Create view v_chenyu as Select MAtime ,salary+count(*) awardsFrom MA,adviser Where MA.ano=adviser.ano and aname= 陈宇Group by MAtime 6. 妇女节到了,给所有VIP 的女会员增加 3%的折扣 4 分 Update members Set discount=discount+3 Where type= VIP and csex= 女五、15 分 设有属于 1NF 的关系模式 R=A, B, C, D, E,R上的函数依赖集F = AD,ED B, BCD , DCA 5 分 1. 计算 (DC)+、(BC)+,(CE)+DC)+ = ACD (BC)+ = ABCD (CE)+ = ABCDE 2. 写出 R 的所有候选码。
5 分 R 的候选码只有一个CE 3. R 是否属于 3NF?为什么? 5 分 R 不属于 3NF,因为 R上只有一个超码 CE,非平凡函数依赖DC A,DC 不是 R 的超码,并且 A 不是超码中的属性六、10 分设有如下调度 S,判别 S是否为冲突可串行化调度如果是,给出等价的串行化调度;如果不是,说明理由T1T2T3T4read(C) read(A) read(B) write(B) read(D) read(B) write(C) write(A) write(D) write(B) read(C) read(D) write(D) read(A) write(A) write(C) 答:S 为不可串行化调度,因为优先图中出现回路T3 T2 T4 T1 T1 T2 T4 T3 或。
