数据库系统原理》试卷-A卷-试题-答案

北京邮电大学2007 —— 2008学年第2学期《数据库系统原理》期末考试试题(A)1. Fill in blanks.(1 9 points)(1) ______ DDL ____ i s the Ianguage for specifying the database schema and as well as otherproperties of the data.(2) With respect to in tegrity mecha ni sms in DBS, —trigger __ defi nes acti ons to be executed automatically whe n some events occur and corresp onding con diti ons are satisfied.(3) An entity set that does not have sufficient attributes to form a primary key is termed aweak en tity set(4) The com monly-used schemes of orga ni zati on of records in files are heap file organization , sequential file organization, and hashing file organization.(5) The three steps in query processing are parsing and translation, optimization, and evaluation(6) The recovery-management component of a database system implements the support for tran sact ion atomicity and durability .(7) A cascadeless schedule ensures that the abort of a transaction does not result in cascadi ng aborts of other tran sact ions.(8) The stric two-phase lock protocol requires that all exclusive-mode locks take n by a tran sact ion be held un til that tran sact ion commits.(9)The three types of failures in DBS are the tran sacti on failures, system crash, and _ failures/crash .2. Choicer11 points)(1) With respect to DBS design , the index is designed at the _____ D ______ phase. A. requireme nt an alysis B. con ceptual desig n C. logical desig nD. physical desig n(2) For the E-R diagram given below, the mapping cardinality from A to B is ______ CA. on e-to-ma nyB. on e-to-oneC. many-to-oneD. many-to-ma ny(3) The follow ing SQL stateme nt corresp onds to the expressi on C .Select * From r , s A. r A s B. r ^sC. r X sD. r — s(4) Given the schema R(A, B, C, D, E, F) and the functional dependencies F={AB D, BCr E, D —■ F, AB > F, CE > B} holding on it, ______ D is a transitive functional depe ndency.A. AB —DB. BC — EC. D - FD. AB —FE. CE >B(5) Given a relation r (R), which one of the following functional dependencies is satisfied by(6) In a Select stateme nt, C ca n be used to take out repetiti on tuples.A B C 1 6 2 4 5 6 4 6 6 7 3 8 91T B T T C diskr .A. uniqueB. countC. dist inctD. union(7) In SQL Ian guage, the stateme nt that can be used for security con trol is ___ CA. i nsertB. rollbackC. revokeD. update(8) All in formatio n except D bel ong to meta-data and are stored in the data dictio nary.A. n ames of the relati onsB. n ames of the authorized usersC. attributes on which the index is definedD. tuples in the relations(9) For three relations r, s, t, their sizes satisfy | r | < | s | < | t |, which of the followingexpressi on may have the lowest evaluati on cost ? ____ AA. (r OO s) OO tB. r O S O t)C. (r OO t) OO sD. ( S O t) ocr(10) As for the followi ng equivale nee rules for tran sformatio n of relati onal expressi ons, whichone is not right? AA. 1 1L(E I U E2)= U【L(E i)) U E2B. 二YE1 -E2)= 门(E1)-二土E2)C. E i - E2 = E2 - E iD 匕(E1 X E2) =E1 O E2(11) Considering the transaction states, after a transaction executes its final statement, e.g.commit, it enters into the B _________ state.A. activeB. partially committedC. failedD. abortedE. committed3. (18 points). Here is the schema diagram for CAP database. Some definitions for the attributes in the table customer,agentq代理商),products and orders(订单)are also given in the following list. The customers order products from the agents. Each time an order is placed, a new row is in serted into the orders table.attributes data types defi niti onsc_id int unique identifier for the customer; similar definitionss fora_id, p_id, ord_noc_n ame varchar(10) name of the customer similar definitions for a_name andp_n amec_city varchar(10) city where the customer is located; similar definitions fora_city and p_citydisco unt real each customer has a n egotiated disco unt (折扣) on pricesqua ntity real qua ntity of the product on hand for sale, in sta ndard un itsprice real price of each un it producto_date date the year and month the order was pacledqty real the total quantity ordered for the productdollars real the cost for the ordered product i n this orderagentsUse the SQL stateme nts to impleme nt the followi ng operati ons:(1) Define the table orders, it is assumed that the null value is inappropriate for the attribute qtyand the attribute dollars ranges from 100 to 10,000. (4 points)(2) Find out the name of each customer who orders all his products through only one agent.(5 points) (3) Give every customer, who places some orders and the total cost (in dollars ) of all theseorders is more than $2000, a 10% increase in the discount he receives. (5 points)(4) Create a new table called Huabei_customers, and add into it all customers who purchasethe product “TV ”and are located in Beijing, Tianjing and Shijz. (4 points)Answer:(1) create table orders( ord_no int, o_date date, c_id int, a_id int, p_id int, qty real not null,dollars real, primary key (ord_no), foreign key (c_id) references customer, foreign key(a_id) references agents, foreign key (p_id) references products, check (dollarsbetween 100 and 10000))(2) 解法一:select c_namefrom customer,orderswhere customer.c_id = order.c_idgroup by c_id,c_namehaving count(distinct a_id ) = 1 解法二:select c_namefrom (select distinct customer. c_name,count (orders.a_id) as agent_number from customer,orderswhere customer.c_id = orders.c_idgroup by orders.c_id)where agent_number = 1 解法三:with cAgent(c_id,a_num) asselect c_id,count (distinct a_id)from ordersgroup by c_idselect c_namefrom customer, cAgentwhere customer.c_id = cAgent.c_id and cAgent.a_num = 1(3) update customerset discount = discount * 1.1where c_id in (select c_idfrom ordersgroup by c_idhaving sum (dollars) > 2000)(4) 解法一:create table Huabei_customers(int,c_idc_name varchar(10), c_city varchar(10), discount real;primary key (c_id)insert into Huabei_customersselect customer.c_id ,c_name,c_city,discountfrom customer,orders,productswhere customer.c_id = orders.c_id and products.p_id = orders.p_idand p_name = TV‘'and p_city in{ ‘Beijing ','Tianjing ','Shijz '}解法二:create table Huabei_customers(c_id int,c_name varchar(10),c_city varchar(10),discount real;primary key (c_id)select customer.c_id ,c_name,c_city,discount into Huabei_customersfrom customer,orders,productswhere customer.c_id = orders.c_id and products.p_id = orders.p_id and p_name =TV‘'and p_city in ( ‘Beijing ','Tianjing ','Shijz ')4. (12 points) The functional dependency set F={ AB C, A DEI, B FH, FGH,D IJ } holds on the relation schema R = (A, B, C, D, E, F, G, H, I, J),a. Compute (AF) +(3 points)b. List all the candidate keys of R. (2points)c. Compute the canonical cover F c (3 points)d. Give a lossless and dependency-preserving decomposition of R into 3NF. (4 points) Answer:a. (3 points)(AF)+ result=AFA T DEI result=AFDEIF T GH result=AFDEIGHD t IJ result=AFDEIGHJb. (2 points)(AB) + =ABCDEFGHc. (3 points)_Fc={ AB t C , A t DE, B t F, F t GH , D t IJ }d. (4 points)R1(A,B,C)R2(A,D,E)R3(D,I,J)R4(B,F)R5(F,G,H)5. (20 points) Notown Records company needs to store information about songs, albums andmusicians who perform on its albums in a database. Consider the following information:Each musicians that records at company has an Id (which is unique), a name , an address, and a phone number.Each instrument used in company has a name and an ID, ID is unique.Each album recorded on the Notown label has a title, a copyright date, a format, and analbum identifier.Each song recorded at Notown has a title and an author, and each song can be identified by title.Each musician may play several instruments ,and a given instruments may be played by several musicians.Each album has a number of songs on it, but no song may appear on more than one album.Each song is performed by one or more musicians, and a musician may perform a number of songs.Each album has exactly one musician who acts as its producer. A musician may produce several albums, of course.(1) Design the E/R diagram for hospital database on basis of the information mentionedabove .(10 points)Note: mapp ing card in ality of each relati on ship and participati on of each en tity to the relati on ship should be described in the diagram.(2) Convert the E-R diagram to the proper relati onal schemas, and give the primary keys of eachrelati on schemas by un derl in es. (10 poin ts)Answers :全参与和部分参与可有不同答案。

合集下载

(完整版)数据库系统原理试卷A

(完整版)数据库系统原理试卷A

东莞理工学院(本科)试卷(A卷)2014--2015学年第1学期《数据库系统原理》试卷开课单位:计算机学院,考试形式:闭卷一、单项选择题(从每小题的四个备选答案中,选出一个正确的答案,并将其代码填入以下表格内。

每小题2分,共401.下述关于数据库系统的正确叙述是( )。

A.数据库系统减少了数据冗余B.数据库系统避免了一切冗余C.数据库系统中数据的一致性是指数据类型一致D.数据库系统比文件系统能管理更多的数据2. 数据库系统的最大特点是( )。

A.数据的三级抽象和二级独立性B.数据共享性C.数据的结构化D.数据独立性3. 自然连接是构成新关系的有效方法。

一般情况下,当对关系R和S使用自然连接时,要求R和S含有一个或多个共有的( )。

A.元组B.行C.记录D.属性4.关系模式的任何属性( )。

A.不可再分B.可再分C.命名在该关系模式中可以不惟一D.以上都不是5、关系模型中,一个关键字是( )。

A.可由多个任意属性组成B.至多由一个属性组成C.可由一个或多个其值能惟一标识该关系模式中任何元组的属性组成D.以上都不是6.SQL语言是( ) 的语言,易学习。

A.过程化B.非过程化C.格式化D.导航式7.假定学生关系是S(S#,SNAME,SEX,AGE),课程关系是C(C#,CNAME,TEACHER),学生选课关系是SC(S#,C#,GRADE)。

要查找选修“COMPUTER”课程的“女”学生姓名,将涉及到关系( )。

A.S B.SC,C C.S,SC D.S,C,SC8.关系数据模型()。

A.只能表示实体间的1 :1 联系B.只能表示实体间的1 :n 联系C.只能表示实体间的m :n 联系D.可以表示实体间的上述3 种联系9.关系运算中花费时间可能最长的运算是( )。

A.投影B.选择C.笛卡尔积D.除10.在数据库系统中,保证数据及语义正确和有效的功能是( )。

A.并发控制B.存取控制C.安全控制D.完整性控制11.规范化过程主要为克服数据库逻辑结构中的插入异常,删除异常以及( )的缺陷。

《数据库原理》试卷(A和B卷)-答案

《数据库原理》试卷(A和B卷)-答案

《数据库原理》试卷答案(A)一、单项选择题 (本大题共15小题,每小题2分,共30分) 在每小题列出的四个选项中只有一个是符合题目要求的,请将其代码填在题后的括号内,错选或未选均无分。

1. A2. B3. B4. A5. C6. C7. A8. A9. C 10. B 11. C 12. D 13. C 14. A 15.B二、填空题 (本大题共10小题,每小题1分,共10分,将正确的答案写在每小题的空格内。

错填或不填均无分。

)1. 可重用性 (或共享性)2. 层次模型。

3. 谓词演算4. 自反5. B→C6. 重构条件7. 不一致分析8. 隔离性9. 简单 (或容易)10. 子类型三、简答题 (本大题共5小题,每小题4分,共20分)1.什么是多值依赖中的数据依赖?举例说明。

答:在关系模式中,函数依赖不能表示属性值之间的一对多联系,这些属性之间有些虽然没有直接关系,但存在间接的关系,把没有直接联系、但有间接的联系称为多值依赖的数据依赖。

例如,教师和学生之间没有直接联系,但教师和学生可通过系名,或任课把教师和学生联系起来。

2.请阐述在网状模型和关系模型中,实体之间联系的实现方法。

答:在网状模型中,联系用指针实现。

在关系模型中,联系用关键码 (或外键,或关系运算) 来实现。

3. 设有两个关系R (A,B,C) 和S (C,D,E),试用SQL查询语句表达下列关系代数表达式πA,E (σ B = D (R∞S))。

答:SELECT A,EFROM R,SWHERE B = D AND R.C = S.C4. 什么是对象关系数据模型?答:在传统的关系数据模型基础上,提供元组、数组、集合等数据类型以及处理新的数据类型操作的能力,这样形成的数据模型,称为“对象关系数据模型”。

5. 设有关系R和S,其中R为参照关系,S为信赖关系。

为了实现完整性约束,SQL规定可以对R的删除操作采取哪三种措施?答:(1) RESTRICT (或约束删除)(2) CASCADE (或级联删除)(3) SET NULL (或外键值置空)四、设计题 (本大题共5小题,每小题6分,共30分)1. 设有关系数据库:职工关系EMPLOYEE (职工号,职工名,街道,城市)工作关系WORKS (职工号,公司号,工资)公司关系COMPANY (公司号,公司名,城市)假设职工可在多个公司兼职,试用SQL语句写出下列操作:将所有在“联华公司”工作的职工加薪5﹪。

数据库原理试卷A(标准答案)

数据库原理试卷A(标准答案)

单项选择题(在每小题的四个备选答案中,选出一个正确答案,并将正确答案的序号填在答题卡上。

每小题1分,共20分)1.数据模型的三要素中,数据的约束条件规定数据及其联系的( A )。

A. 制约规则B. 静态特性C. 动态特性D. 数据结构2.DB、DBMS、DBS三者之间的关系是( B )。

A. DBMS包括DB和DBSB. DBS包括DB和DBMSC. DB包括DBMS和DBSD. DB、DBMS、DBS是同一个意思3.有一个关系:学生(学号,姓名,系别),规定学号的值域是9个字符组成的字符串,这一规则属于( C )。

A. 实体完整性约束B. 参照完整性约束C. 用户自定义完整性约束D. 关键字完整性约束4.有12个实体类型,并且它们之间存在着15个不同的二元联系,其中4个是1:1联系类型,5个是1:N联系类型,6个M:N联系类型,那么根据转换规则,这个ER结构转换成的关系模式至少有( B )。

A.17个B.18个C.23个D.27个5.在数据库技术中,未提交的随后被撤消了的数据,称为( D )。

A.报废的数据B.过时的数据C.撤消的数据D.脏数据6.嵌入式SQL的预处理方式,是指( D )。

A.识别出SQL语句,加上前缀标识和结束标志B.对源程序进行格式化处理C.把嵌入的SQL语句编译成目标程序D.把嵌入的SQL语句处理成函数调用形式7.若系统在运行过程中,由于某种硬件故障,使存储在外存上的数据部分损失或全部损失,这种情况称为( A )。

A. 介质故障B. 运行故障C. 系统故障D. 事务故障8.如果事务T获得了数据项Q上的排它锁,则T对Q( C )。

A. 只能读不能写B. 只能写不能读C. 既可读又可写D. 不能读也不能写9.在SQL的下列语句中,能够实现参照完整性约束的语句( D )。

A.FOREIGN KEY B.PRIMARY KEYC.REFERENCES D.FOREIGN KEY和REFERENCES10.在需求分析阶段,数据字典是对系统中( A )。

数据库试题及答案_两套[1]

数据库试题及答案_两套[1]

数据库试题及答案两套收藏数据库原理试题(A卷)一、填空题(每空 1 分,共 20 分)1. 对于一个国家来说,数据库的建设规模、数据库信息量的 _安全性____________ 和 ____完整性_________ 已成为这个国家信息化程度的 _______衡量标准_________ 。

2. 数据模型通常由: ___数据结构_____________ 、_______数据操作_________ 和 __完整性约束___________ 三部分组成。

3. 游标的功能是把 __集合记录______________ 转换为 ___单记录_____________ 。

4. 最常用的数据库的恢复技术是_数据转储____________ 和 _登记日志文件__________。

5. __概念_____ 模型是现实世界到 __数据模型___________ 机器模型的中间桥梁。

6. 数据独立性是指___物理________ 和__逻辑___________ 独立性。

7. 数据库应用程序开发工具目前有_ C++, _____________ 、__________VB_______ 、_______DEF_________ 、和 ____________C#____ 等。

8. 目前数据库产品有 SQL Server 和 ____ORACLE____________ 、 ___ACESS_____________ 等。

二、选择题(每小题 1 分,共 10 分)1. 关于冗余数据的叙述中,不正确的是 (C ) 。

A .冗余的存在容易破坏数据库的完整性B .冗余的存在给数据库的维护增加困难.C .不应该在数据库中存储任何冗余数据D .冗余数据是指可由基本数据导出的数据2. 概念模型独立于 (C ) 。

A . ER 模型B .硬件设备C . DBMSD .操作系统3. 下列叙述正确的为(D )。

A. 主码是一个属性,它能唯一表识一列B. 主码是一个属性,它能唯一表识一行C. 主码是一个属性或属性集,它能唯一表识一列D. 主码是一个属性或属性集,它能唯一表识一行4. 数据库三级模式体系结构的划分,有利于保持数据库的 (A ) 。

《数据库原理》期末试卷及答案(A)

《数据库原理》期末试卷及答案(A)

只有一个是符合题目要求的,请将其代码填在题后的括号内。

错选或未选都无分。

)1、A2、D3、C4、A5、B6、A7、C8、D9、B 10、D11、B 12、C 13、B 14、D 15、B16、D 17、B 18、D 19、B 20、B二、填空题(本大题共10小题,每小题1分,共10分。

将正确的答案填在每小题的空格内。

错填或不填均无分)21、程序22、m×n23、自然连接24、CREATE INDEX25、聚簇索引26、元组27、空值28、授权29、投影30、GROUP BY三、名词解释(本大题共5小题,每小题3分,共15分)31、数据库管理系统是数据库系统的核心,是为数据库的建立、使用和维护而配置的软件。

它建立在操作系统的基础上,是位于操作系统和用户之间的一层管理软件,负责对数据库进行同一的管理和控制。

它的功能主要包含6个方面:(1)数据定义(2)数据操纵(3)数据库进行管理(4)数据组织、存储和管理(5)数据库的建立和维护(6)数据通信接口32、完全函数依赖:在关系模式R(U)中,如果X→Y,并且对于X的任何一个真子集X’,都有,则称Y完全函数依赖于X。

33、视图视图是从一个或几个基本表(或视图)导出的表,它与基本表不同,是一个虚表。

数据库中只存放视图的定义,而不存放视图对应的数据,这些数据仍存放在原来的基本表中。

基本表中的数据发生变化,从视图中查询出的数据也随之发生变化。

从这个意义上讲,视图就像一个窗口,透过它可以看到数据库中自己感兴趣的数据及其变化。

34、主码和主属性如果关系中的某一个属性组的值能够唯一地标识一个元组,而其子集不行,则称该属性组为侯选码。

若一个关系有多个侯选码,则选定其中一个为主码。

侯选码的诸属性称为主属性。

35、游标游标是系统为用户开设的一个数据缓冲区,存放SQL的执行结果。

嵌入式SQL用游标来协调SQL语言与主语言之间的数据处理。

每个游标区都有一个名字。

用户可以用SQL语句逐一从游标中获取记录,并赋给主变量,交由主语言进一步处理。

数据库试题四A

数据库试题四A

数据库系统原理试题四(A卷)一、选择题(每小题1分,共10分)1.SQL语言有两种使用方式,分别为交互式SQL和 C 。

A. 提示式SQL;B. 多用户SQL;C. 嵌入式SQL;D. 解释式SQL。

2. 授权编译系统和合法性检查机制一起组成了 A 子系统。

A. 安全性;B. 完整性;C. 并发控制;D. 恢复。

3. 为了防止一个用户的工作不适当地影响另一个用户,应该采取 C 。

A 完整性控制B 安全性控制C 并发控制D 访问控制4. 在SQL的SELECT语句中,实现投影操作的是哪个子句?A SELECTB FROMC WHERED ORDER BY5. 网状模型的数据结构是 D 。

A.线性表 B.二维表C.树 D.有向图6. 主键的属性上有空值违反了 A 。

A.实体完整性规则 B.参照完整性规则C.安全性规则 D.模型转换规则7. 两个关系的 D 运算不要求这两个关系具有相同的关系模式。

A.并 B.交C.差 D.连接8. 设有关系模式R(ABCD),R上的FD集F={A→D,B→C,D→B}。

则D= C 。

A.AD B.BDC.BCD D.ABCD9. 在DB技术中,“脏数据”是指 D 。

A.未回退的数据 B.未提交的数据C.回退的数据 D.未提交随后又被撤销的数据10. 在XPath中,使用符号可以访问属性值。

A.* B.& C.@ D.%二、填空题(每空1分,共10分)1.事务必须具有的四个性质是原子性、一致性、隔离性、持久性。

2. 一个触发器由_条件_______、事件和动作 3部分组成。

3. 关系模式在分解时应保持等价,数据等价用无损分解特征来衡量,语义等价用特征来衡量。

4. 要使数据库具有可恢复性,在平时要做好两件事:转储和建立日志。

7. 并发控制的主要方法是采用___封锁机制_____________。

三、简答题(每小题4分,共20分)1. 叙述等值连接和自然连接的区别和联系。

中山大学软件学院本科生期末考试《数据库系统原理》(A卷)

中山大学软件学院本科生期末考试考试科目:《数据库系统原理》(A卷)学年学期:2014学年第3学期姓名:学院/系:软件学院学号:考试方式:开卷年级专业:考试时长:120分钟班别:第八条:“考试作弊者,不授予学士学位。

”------------以下为试题区域,共7道大题,总分100分,考生请在答题纸上作答------------1. (10 marks) Let R = {A, B, C, D, E, F, G} and F = {AB→C, A→C, A→E, B→C, EF→EG, G→F}. Answer the following three questions.1)(4 marks) Compute the minimal cover of F.B→CA→CA→EEF→GG→F2)(4 marks) Decompose R into 3NF relations.{B, C}, {A, C, E}, {E, F, G} and {A, B, D, F} (OR {A, B, D, G})3)(2 marks) Is the composition in (b2) in BCNF? Briefly explain your answer.No. For {E, F, G} and G→F, G is not a candidate key.2. (10 marks)Assume there is an employee database Employee (eid: 8 bytes, ename: 16 bytes, did: 4 bytes, email: 12 bytes), where eid and ename are respectively the id and name of an employee and did is the id of the department in which the employee works. Suppose there are 50,000 employee records and 500 departments (i.e. each department has 100 employees on average). A page size is 1,000 bytes and a pointer costs 4 bytes.1)(4 marks) Assume that the employee file is sorted sequentially on did and there is noindex. Estimate the page access cost for retrieving the records of all employees working in a department with a given did. (You should show your argument and the main steps of the estimation clearly in the answer.)AnswerRecord size = 40 bytes, 25 records per page, 2,000 pages.Finding the first record requires log22000 + 3 more pages to search theremaining records (each dept has 100 employees which are distributed in 4pages).2)(6 marks) Assume only 20 pages of main memory are available for running theexternal sorting of the employee file on did.•How many PASSes are needed for the external sorting?•In each PASS, how many runs are created?•What is the total cost of the sorting in terms of pages?Answer:3 PASSes:PASS 0: 2000 pages / 20 pages per run = 100 runsPASS 1: ceil (100 runs / 19 runs per run) = 6 runsPASS 2: 1 runTotal cost: (2000 pages read per pass + 2000 pages write per pass) * 2 PASSes +2000 pages read per pass = 10000 pages (Note: Output is not counted!)Or: 2000 * (2 * 2 + 1) = 10000 pages transfer.3. (10 marks) Suppose a bookstore has the following five relational tables:BOOK (BID, TITLE, AID, SUBJECT, QUANTITY_IN_STOCK)AUTHOR (AID, NAME) CUSTOMER (CID, NAME)ORDER_DETAILS (OID, BID , QUANTITY) ORDER (OID, CID , ORDER_YEAR)In the above tables, keys are underlined and foreign keys are in italics . Each author has authored at least one book in the store. Each book has exactly one author. Each order is made by exactly one customer and has one or more associated record in ORDER_DETAILS (e.g., an order may contain different books).Express the following query using (i) SQL expressions, (ii) the relational algebra (RA).Find the distinct customer IDs (CID) of customers who have purchased more than 10 identical books in one order at least once.(i) SELECT DISTINCT CIDFROM ORDER_DETAILS od, ORDER oWHERE QUANTITY >= 10 AND od.OID = o.OID(ii)CID (σQUANTITY ≥ 10 (ORDER_DETAILSOID ORDER ))4. (10 marks) A B+ tree with n=5 is shown in Figure 1, in which only search keys are shown and pointers to the file system are hidden. We want to insert a data entry with search key “23”.Figure 1. A B+ Tree Structure1) Which of the following descriptions about the insertion operation is correct?A.The B+ tree contains 2 levels after insertion. 2 node splits are needed duringinsertion. The root node contains search key “15”.B.The B+ tree contains 3 levels after insertion. 1 node split is needed duringinsertion. The root node contains search key “20”.C.The B+ tree contains 3 levels after insertion. 2 node splits are needed duringinsertion. The root node contains search key “15”.D.The B+ tree contains 3 levels after insertion. 2 node splits are needed duringinsertion. The root node contains search key “20”.Answer: C2)We want to delete the data entry with search key “7”. How many leaf nodes store onlytwo data values after deletion?A.2B. 3C. 4D.5Answer: A5. (20 marks)You are given an initial hash structure with three keys already inserted as below. The hash function is h(x) = x mod 16. Draw five extendable hash structures corresponding for each insertion of the following search key values K: 7, 15, 20, 37, 18. Assume each bucket can hold two keys and the search key values arrive in the given order (i.e. 7 being the first coming key and 18 being the last one).You should follow the convention used by lecture slides: binary hash indices starting from the least significant bit. (E.g. 1 is the least significant bit of the 4 digit binary number 0001.)AnswerInsert 7Insert 15 and 20Insert 37Insert 186. (25 Marks) Consider a database consisting of the following three relation schemas:SAILORS (sid, sname, rating, age)BOATS (bid, bname, color)RESERVES (sid, bid, date, rname)The meaning of the attributes in the above schemas is self-explanatory. For example, sid is the sailor identity number and bname is the name of the boat. The primary keys of the relations are underlined. The attribute sid in RESERVES is a foreign key referencing SAILORS. The attribute bid in RESERVES is a foreign key referencing BOATS.The relation SAILORS has 100,000 tuples and 100 tuples of SAILORS fit into one page. The relation BOATS has 50,000 tuples and 25 tuples of BOATS fit into one page. The relation RESERVES has 10,000 tuples and 20 tuples of RESERVES fit on one page. We assume all attribute values and pointers in these three relations, if needed to be considered, are of the same size.(a)(10 marks) Assume that we use Indexed Nested Loop Join to computeSAILORS RESERVES using SAILORS as the outer relation. RESERVES have a primary B+-tree index with 2 levels on the join attribute. Estimate the cost of the join in terms of pages.Number of SAILORS pages: br = 100,000/100 = 1,000Number of SAILORS Tuples: nr = 100,000.The cost is br+ c * nr = 1,000 + (2+1) * 100,000 = 301,000.(b)(5 mark)Assume that 26% of the sailors have the rating bigger than 5. Estimate theresult size of sid(σrating>5 SAILORS) in terms of pages.Size = 26% * 100,000 / 100/4 = 65 pages260 divided by 4, for there is projection and all the attributes have same size(c)(10 marks) Consider the following two strategies to compute the join operationSAILORS BOATS RESERVES.Strategy 1: (SAILORS BOATS) RESERVESStrategy 2: (SAILORS RESERVES) BOATSWhich strategy is better? Explain the reason(s) of your choice based on the size of the intermediate result using the above strategies.Strategy 2 is better.Because in Strategy 1, SAILORS BOATS is equal to the cross-product of the two relations and the size of the join result will become as large as 100,000 * 50,000 = 5,000,000,000 tuples. This intermediate result is very large and later when joining this intermediate result with RESERVES, the cost is also large.In comparison, in Strategy 2, SAILORS RESERVES has only 10,000 tuples. And later when joining this intermediate result with BOATS, the cost is also small.7. (15 Marks) Consider a schedule S which consists of four transactions as follows:S = <T3_R(U), T2_R(X), T2_W(X), T3_R(X), T1_R(Y), T1_W(Y), T3_W(X), T1_R(Z), T4_R(Z), T4_W(Z), T2_W(Y), T3_R(Y)>The notation is self-explanatory. For example, T1_R(X) means that transaction T1 reads item X.(a)(5 marks) Fill in the following table representing S with the usual notations in lectureslides. The first operation R(U) has been shown in the table. Show clearly all conflicting pairs with downward arrows on the operations.(b)(5 marks) Construct the precedence graph of S. Explain why or why not the schedule isconflict-serializable.Precedence Graph of S:No cycle.(c)(5 marks) Suppose the format of the “commit” operation is Ci where i = 1, 2, 3, or 4.For example, the operation C1 means that the transaction T1 commits. Append all the commit statements to S so that the schedule becomes recoverable. For example, one append can be SC4C3C2C1 which means running S and then C4, C3, C2, C1. (Note that you should NOT change the sequence of the operations in S other than appending S with the four commit statements to make the schedule recoverable.)Recoverable (but not cascadeless) schedule: SC1C2C3C4 or (SC1C2C4C3) or (SC1C4C2C3) (Note: any permutation of Ci satisfies the commit order constraints: C1→C2, C1→C3, C1→C4, C2→C3 is correct)。

(完整版)数据库原理试卷带答案

数据库原理试卷A一、单选题(本题共20个小题,每题1分,共20分。

答案唯一,多选或少选均不得分。

请将答案按对应的题号写在下面的表格中)1.下述关于数据库系统的正确叙述是( A )。

A. 数据库系统减少了数据冗余B. 数据库系统避免了一切冗余C. 数据库系统中数据的一致性是指数据类型一致D. 数据库系统比文件系统能管理更多的数据2. 数据库(DB),数据库系统(DBS)和数据库管理系统(DBMS)之间的关系是( A )。

A. DBS包括DB和DBMSB. DBMS包括DB和DBSC. DB包括DBS和DBMSD. DBS就是DB,也就是DBMS3. 描述数据库全体数据的全局逻辑结构和特性的是( A )。

A.模式B. 内模式C. 外模式D. 用户模式4. 要保证数据库的逻辑数据独立性,需要修改的是(A )。

A. 模式与外模式的映射B. 模式与内模式之间的映射C. 模式D. 三层模式5. 数据库系统的数据独立性体现在( B )。

A.不会因为数据的变化而影响到应用程序 B.不会因为系统数据存储结构与数据逻辑结构的变化而影响应用程序 C.不会因为存储策略的变化而影响存储结构D.不会因为某些存储结构的变化而影响其他的存储结构6. 在一个关系中如果有这样一个属性存在,它的值能惟一地标识关系中的每一个元组,称这个属性为( C )。

A. 关键字B. 数据项C. 主属性D. 主属性值7. 现有如下关系: 患者(患者编号,患者姓名,性别,出生日起,所在单位) 医疗(患者编号,患者姓名,医生编号,医生姓名,诊断日期,诊断结果) 其中,医疗关系中的外码是( D )。

A. 患者编号B. 患者姓名C. 患者编号和患者姓名D. 医生编号和患者编号8. 自然连接是构成新关系的有效方法。

一般情况下,当对关系R和S使用自然连接时,要求R或S含有一个或多个共有的( D )。

A. 元组B. 行C. 纪录D. 属性9. 有关系SC(S_ID,C_ID,AGE,SCORE),查找年龄大于22岁的学生的学号和分数,正确的关系代数表达式是( D )。

《数据库原理》期末试卷及答案(A)

只有一个是符合题目要求的,请将其代码填在题后的括号内。

错选或未选都无分。

)1、A2、D3、C4、A5、B6、A7、C8、D9、B 10、D11、B 12、C 13、B 14、D 15、B16、D 17、B 18、D 19、B 20、B二、填空题(本大题共10小题,每小题1分,共10分。

将正确的答案填在每小题的空格内。

错填或不填均无分)21、程序22、m×n23、自然连接24、CREATE INDEX25、聚簇索引26、元组27、空值28、授权29、投影30、GROUP BY三、名词解释(本大题共5小题,每小题3分,共15分)31、数据库管理系统是数据库系统的核心,是为数据库的建立、使用和维护而配置的软件。

它建立在操作系统的基础上,是位于操作系统和用户之间的一层管理软件,负责对数据库进行同一的管理和控制。

它的功能主要包含6个方面:(1)数据定义(2)数据操纵(3)数据库进行管理(4)数据组织、存储和管理(5)数据库的建立和维护(6)数据通信接口32、完全函数依赖:在关系模式R(U)中,如果X→Y,并且对于X的任何一个真子集X’,都有,则称Y完全函数依赖于X。

33、视图视图是从一个或几个基本表(或视图)导出的表,它与基本表不同,是一个虚表。

数据库中只存放视图的定义,而不存放视图对应的数据,这些数据仍存放在原来的基本表中。

基本表中的数据发生变化,从视图中查询出的数据也随之发生变化。

从这个意义上讲,视图就像一个窗口,透过它可以看到数据库中自己感兴趣的数据及其变化。

34、主码和主属性如果关系中的某一个属性组的值能够唯一地标识一个元组,而其子集不行,则称该属性组为侯选码。

若一个关系有多个侯选码,则选定其中一个为主码。

侯选码的诸属性称为主属性。

35、游标游标是系统为用户开设的一个数据缓冲区,存放SQL的执行结果。

嵌入式SQL用游标来协调SQL语言与主语言之间的数据处理。

每个游标区都有一个名字。

用户可以用SQL语句逐一从游标中获取记录,并赋给主变量,交由主语言进一步处理。

数据库系统概论试题和答案及填空题

数据库系统概论试卷(A)一、选择题(15x1分)1、__C___是长期存储在计算机内的有组织,可共享的数据集合.A、数据库管理系统B、数据库系统C、数据库D、文件组织2、在数据库中存储的是__C___。

A、数据B、数据模型C、数据以及数据之间的联系D、信息3、数据库系统阶段,数据___D__。

A、具有物理独立性,没有逻辑独立性B、具有物理独立性和逻辑独立性C、独立性差D、具有高度的物理独立性和一定程度的逻辑独立性4、在数据模型的三要素中,数据的约束条件规定数据及其联系的__A___。

A、制约和存储规则B、动态特性C、静态特性D、数据结构5.___A_____由数据结构、关系操作集合和完整性约束三部分组成。

A、关系模型B、关系C、关系模式D、关系数据库6、一组具有相同数据类型的值的集合称为____D____。

A、关系B、属性C、分量D、域7、集合R与S的交可以用关系代数的5种基本运算表示为____A____。

A、 R-(R-S)B、σF(R×S)C、R-(S-R)D、S-(R-S)8、实体是信息世界中的术语,与之对应的数据库术语为___D____。

A、文件B、数据库C、字段D、记录9、在嵌入式SQL语言中使用游标的目的在于____D____。

A、区分SQL与宿主语言B、与数据库通信C、处理错误信息D、处理多行记录10、FoxBASE、FoxPro属于____B____。

A、表式系统B、最小关系系统C、关系完备的系统D、全关系系统11、在R(U)中,如果X→Y,并且对于X的任何一个真子集X',都没有X'→Y,则____A____。

A、Y函数依赖于XB、Y对X完全函数依赖C、X为U的候选码D、R属于2NF12、3NF___C_____规范为BCNF。

A、消除非主属性对码的部分函数依赖B、消除非主属性对码的传递函数依赖C、消除主属性对码的部分和传递函数依赖D、消除非平凡且非函数依赖的多值依赖13、下面的结论不正确的是___D___。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
相关文档
最新文档