《数据库理论与技术》复习题-2008小妖版
数据库原理考试题库及答案

数据库原理考试题库及答案选择题1.同一个关系模型的任意两个元组值(A)。
A. 不能全同B. 可全同C. 必须全同D. 以上都不是2.关系模式R中的属性全部是主属性,则R的最高范式必定是(B )。
A. 2NFB. 3NFC. BCNFD. 4NF3.下列哪个不是数据库系统必须提供的数据控制功能(B)。
A. 安全性B. 可移植性C. 完整性D. 并发控制4.若关系R的候选码都是由单属性构成的,则R的最高范式必定是( B )。
A. 1NFB. 2NFC. 3NFD.无法确定5.下列哪些运算是关系代数的基本运算( D )。
A. 交、并、差B. 投影、选取、除、联结C. 联结、自然联结、笛卡尔乘积D. 投影、选取、笛卡尔乘积、差运算6.SQL语句的一次查询结果是( D )。
A. 数据项B. 记录C. 元组D. 表7.在关系R(R#, RN, S#)和S(S#,SN, SD)中,R的主码是R#, S的主码是S#,则S#在R中称为( A )。
A. 外码B. 候选码C. 主码D. 超码8.在DBS中,DBMS和OS之间关系是(D)。
A. 并发运行B. 相互调用C. OS调用DBMSD. DBMS调用OS9.层次模型、网状模型和关系模型的划分根据是(D)。
A. 记录长度B. 文件的大小C. 联系的复杂程度D. 数据之间的联系10.下列哪个是单目运算( C )。
A. 差B. 并C. 投影D. 除法11.采用SQL查询语言对关系进行查询操作,若要求查询结果中不能出现重复元组,可在SELECT子句后增加保留字( A )。
A. DISTINCTB. UNIQUEC. NOT NULLD. SINGLE12.下列SQL语句中,能够实现“给用户teacher授予查询SC的权限”这一功能的是( A )。
A. GRANT SELECT on SC to teacherB. REVOKE SELECT on SC to teacherC. GRANT SELECT on TABLE to teacherD. REVOKE SELECT on TABLE to teacher13.设有关系S (SNO,SNAME,DNAME,DADDR),将其规范化到第三范式正确的答案是(B)。
《数据库原理》复习题(选择题部分) (1) (2)

《数据库原理》复习题(选择题部分)1.()是长期存储在计算机内的有组织,可共享的数据集合。
(A)数据库管理系统(B)数据库系统(C)数据库(D)文件组织2.()是位于用户与操作系统之间的一层数据管理软件。
(A)数据库管理系统(DBMS)(B)数据库系统(DBS)(C)数据库(D)数据库应用系统3.数据库系统不仅包括数据库本身,还要包括相应的硬件,软件和()。
(A)数据库管理系统(B)数据库应用系统(C)相关的计算机系统(D)各类相关人员4.下列命令不属于DBMS的数据定义语言的是:()。
(A)CREATE(B)DROP(C)INSERT(D)ALTER5.SQL Server 2005是一种()的数据库管理系统。
(A)关系型(B)层次型(C)网状(D)树型6.支持SQL Server 2005 中的所有可用功能,可作为企业数据库服务器使用的SQL Server 2005版本是:()。
(A)SQL Server 2005个人版.(B)SQL Server 2005企业版(C)SQL Server 2005开发版.(D)SQL Server 2005标准版7.SQL Server 2005 企业版可以安装在()操作系统上。
(A)Microsoft Windows 98.(B)Microsoft Windows Me(C)Microsoft Windows 2000 Professional.(D)Microsoft Windows 20038.一个面向主题的,集成的,不同时间的,稳定的数据集合是:()。
(A)分布式数据库(B)面向对象数据库(C)数据仓库(D)联机事务处理系统9.以下()不属于数据库对象(A)表和视图(B)索引和约束(C)T-SQL脚本(D)触发器10.SQL Server 2005的物理数据库构架主要包括()。
(A)文件及文件组.(B)页面和盘区(C)表和视图(D)数据和程序11.SQL Server 2005的数据以页为基本存储单位,页的大小为()。
数据库原理复习题

数据库原理复习题一、单项选择题1、在数据库技术中,独立于计算机系统的模型是___A___。
A.E-R模型 B.层次模型 C.关系模型 D.面向对象的模型2、SQL基本表的创建中是通过____B___实现参照完整性规则的。
A.主键子句B.外键子句C.检查子句D.NOT NULL3、设计性能较优的关系模式称为规范化,规范化的主要理论依据是____A_____。
A.关系规范化理论B.关系运算理论C.代数运算理论D.数理逻辑理论4、用二维表结构表示实体以及实体间联系的数据模型称为____C___。
A.网状模型B.层次模型C.关系模型D.面向对象模型5、假如采用关系数据库系统来实现应用,在数据库设计的____A_____阶段,需要将E-R模型转换为关系数据模型。
A.概念设计B.物理设计C.逻辑设计D.运行阶段6、数据库系统与文件系统的根本区别在于___C______。
A.数据库系统中,数据可共享B.数据库系统中,数据冗余度小C.数据库系统中,整体数据结构化D.数据库系统中,数据库中有记录数据结构信息的数据字典7、从数据库原理上讲,如果一个关系未定义主码,则____D_____。
A.它的第一个属性为主码B.任意属性都是主码C.没有主码D.所有属性构成一个主码8、有关系:教学(学号、教工号、课程号)假定每个学生可以选修多门课程,每门课程可以由多名学生来选修,每个老师可以讲授多门课程,每门课程只能由一个老师来讲授,那么该关系的主码是____C_____。
A.课程号B.教工号C. (学号,课程号)D. (学号、教工号)9、在关系数据库系统中,一个关系中的任意两个元组____A_____。
A.不能全同B.可全同C.必须全同D.以上都不是10、在数据库设计中,可以很方便地把一个E-R模型转换为关系模型,E-R模型与关系模型之间的联系性质为____D_____。
A.一对一B.一对多C.多对多D.以上三种都不对11、数据库管理系统不具备的功能为___C______。
数据库原理及应用期末考试复习题库

一、填空题1.(事务)是用户定义的一个数据库操作序列,是一个不可分割的工作单位,它具有(原子性)、(一致性)、(隔离性)、(持续性)四个特性。
2.(数据库)是长期存储在计算机内的、有组织、可共享的数据集合。
(数据库)是存储在计算机内组织的结构化的相关数据的集合。
3.(事务)是用户定义的一个数据库操作序列,这些操作要么全做要么全不做,是一个不可分割的工作单位。
4.(数据库管理系统)是位于用户与(操作系统)之间的一层数据管理软件。
5.(物理结构设计)阶段与具体的DBMS密切相关。
6.DBMS是指(数据库管理系统)它是位于(用户)和(操作系统)之间的一层管理软件7.E-R图一般在数据库设计的(概念结构设计)阶段使用。
8.RDMBS查询处理可分为(查询分析)、查询检查、(查询优化)和查询执行四个阶段。
9.SQL Server具有两种身份验证模式:(WINDOWS)身份验证模式和(混合)身份验证模式。
10.SQL的(集合)处理方式与主语言的单记录处理方式之间用(游标)来协调。
11.SQL的触发事件有三类:(UPDATE)、(DELETE)和(INSERT)。
12.SQL的授权语句中的关键字PUBLIC表示(全体用户)。
13.SQL中的安全性机制,主要有两个:(视图)和(授权)。
14.S封锁增加了并发度,但缺点是(容易发生死锁)。
15.T-SQL语言中,局部变量由用户定义和维护,名称以(@)开头;全局变量由系统定义和维护,名称以(@@)开头。
16.按所使用的数据模型来分,数据库可分为(层次)、(关系)和(网状)三种类型。
17.按照数据结构的类型来命名,数据模型分为(层次模型),(网状模型)和(关系模型)。
18.表示实体及其联系的方法为(E-R图),基本图素包括(实体)、(属性)和(联系)。
习惯上实体用(矩形)表示,实体属性用(椭圆形)表示,联系用(菱形)表示。
19.并发操作带来的问题主要有(丢失修改),(不可重复读),(读脏数据)。
数据库技术复习题1选择题(答案)

数据库技术复习题1选择题(答案)数据库技术试题⼀、选择题1. 单个⽤户使⽤的数据视图的描述称为A. 外模式B. 概念模式C. 内模式D. 存储模式2. ⼦模式DDL⽤来描述A. 数据库的总体逻辑结构B. 数据库的局部逻辑结构C. 数据库的物理存储结构D. 数据库的概念结构3. 在DBS中,DBMS和OS之间的关系是A. 相互调⽤B. DBMS调⽤OSC. OS调⽤DBMSD. 并发运⾏4. 当关系R和S⾃然联接时,能够把R和S原该舍弃的元组放到结果关系中的操作是A. 左外联接B. 右外联接C. 外部并D. 外联接5. 下列聚合函数中不忽略空值 (null) 的是A. SUM(列名)B. MAX(列名)C. COUNT( * )D. AVG(列名)6. 设关系模式R (A,B,C),F是R上成⽴的FD集,F = {B→C},则分解ρ = {AB,BC}相对于FA. 是⽆损联接,也是保持FD的分解B. 是⽆损联接,但不保持FD的分解C. 不是⽆损联接,但保持FD的分解D. 既不是⽆损联接,也不保持FD 的分解B. 逻辑设计阶段C. 概念设计阶段D. 物理设计阶段8. SQL中,下列涉及空值的操作,不正确的是A. AGE IS NULLB. AGE IS NOT NULLC. AGE = NULLD. NOT (AGE IS NULL)9. ⼀个关系中的候选关键字。
A .⾄多⼀个B .可多个C .必须多个D .⾄少 3 个10. DBMS中实现事务持久性的⼦系统是A. 安全性管理⼦系统B. 完整性管理⼦系统C. 并发控制⼦系统D. 恢复管理⼦系统11. SQL的全局约束是指基于元组的检查⼦句和A. ⾮空值约束B. 域约束⼦句C. 断⾔D. 外键⼦句12. 分布式数据库系统中分⽚模式和分配模式均是A. 全局的B. 局部的C. 分布的D. 集中的13. 属性类型允许是基本数据类型、结构类型和集合类型的模型是A. 平⾯关系模型B. 嵌套关系模型C. 复合对象模型D. 分布式关系模型14. ⽤树型结构表⽰实体之间联系的数据模型称为D.层次模型15. 数据库系统的核⼼是A.数据库B.数据库管理系统C.数据模型D.软件⼯具16. 在SQL语⾔中,与X BETWEEN 10 AND 20等价的表达式是A.X>10 AND X<20B.X>=10 AND X<20C.X>10 AND X<=20D.X>=10 AND X<=2017. 某个E-R图中有5个实体型,2个1∶n联系和2个m∶n联系,则该E-R图转换的关系模式个数⾄少是A.5个B.7个C.8个D.9个18. 若关系模式R(V,F)中的每⼀个决定属性集都包含候选码,则R属于A.2NFB.3NFC.BCNFD.4NF19. 若事务T对数据R已加X锁,则其他事务对数据RA.可以加S锁不能加X锁B.不能加S锁可以加X锁C.可以加S锁也可以加X锁D.不能加任何锁20.在⽬前的并⾏数据库体系结构中,可扩充性最⾼的是A.SMB.SDC.SND.SK21.数据的正确性和相容性是指数据库的A.完整性22.下列不属于事务的特性的是A.隔离性B.⼀致性C.完整性D.原⼦性23.系统在运⾏过程中,由于某种硬件故障,使存储在外存上的数据部分损失或全部损失,这种情况属于A.事务故障B.系统故障C.介质故障D.运⾏故障24.E-R图是数据库设计的常⽤⼯具之⼀,它适⽤于建⽴数据库的A.概念模型B.逻辑模型C.结构模型D.物理模型25.数据库逻辑结构设计的主要任务是A.建⽴E-R图B.把数据送⼊数据库C.建⽴数据流图和需求说明书D.将E-R图转换为某个DBMS所⽀持的数据模型26.下⾯不是SQL语⾔优点的是。
《数据库原理与设计》复习资料

商店与职工之间存在聘任联系,属性有工资,每个职工只能在一家商店工作。
1)试画出E-R图
2)将E-R模型转换为关系模型
五•在数据库逻辑结构设计阶段,将E-R图中的实体以及实体之间联系转换为关系模型具有一定的转换规则,请简述该转换规 则。(15分)
12
:选择题:(每题2分,共30分)
1.
A
2
D
3
A
4
说明:1.试题间不留答题空间,不得超出边框;
人(签字):学院审核(签字):
课程关系C(Cno, CNAM)
其中Sno Cno SNAMEAGE SEX GRADJECNAM分别表示学号、课程号、姓名、年龄、性别、成绩和课程名。
用SQL语句表达下列操作
(1)检索年龄在18到20之间(含18和20)的女生的学号、姓名和年龄
A.由X—Y,Y—乙则X-YZB.由X—YZ,贝UX—Y,Y—Z
C.由X—Y,W—Z,则XV—ZD.由X—Y,Z€Y,则X—Z
14.在关系数据库设计中,设计关系模式是数据库设计中()阶段的任务。
A.逻辑设计阶段B.概念设计阶段
C.物理设计阶段D.需求分析阶段
15.在ER模型中,如果有3个不同的实体集,3个M: N联系,根据ER模型转换为关系模型的规则,转换为关系的数目是()
1.建立数据字典的时机是()
A.需求分析阶段B.数据库物理设计阶
C.数据库实施阶段D.概念结构设计阶段
2.下述()不是DBA数据库管理员的职责。
A.完整性约束说明B.定义数据库模式
C.数据库安全D.数据库管理系统设计
3.下面的选项不是关系数据库基本特征的是()。
A.不同的列应有不同的数据类型B.不同的列应有不同的列名
《数据库原理和应用》总复习试题

《数据库原理及应用》总复习题一、单项选择题〔811.数据库系统的核心是〔。
A数据库B数据库管理系统C操作系统D文件答案:B2.数据库<DB>、数据库系统<DBS>和数据库管理系统<DBMS>之间的关系是< >。
ADBS包括DB和DBMSBDBMS包括DB和DBSCDB包括DBS和DBMSDDBS就是DB,也就是DBMS答案:A3.在数据管理技术的发展过程中,数据独立性最高的是〔阶段。
A数据库系统B文件系统C人工管理D数据项管理答案:A4.数据库系统是由数据库、数据库管理系统〔及其开发工具、应用系统、〔和用户构成。
ADBMSBDBCDBSDDBA〔数据库管理员答案:D5.文字、图形、图像、声音、学生的档案记录、货物的运输情况等,这些都是〔。
ADATABINFORMATIONCDBD其他答案:A6.〔是长期存储在计算机内有序的、可共享的数据集合。
ADATABINFORMATIONCDBDDBS答案:C7.〔是位于用户与操作系统之间的一层数据管理软件。
数据库在建立、使用和维护时由其统一管理、统一控制。
ADBMSBDBCDBSDDBA答案:A8.概念设计的结果是〔A一个与DBMS相关的要领模型B一个与DBMS无关的概念模型C数据库系统的公用视图D数据库系统的数据字典答案:B9. E-R方法的三要素是〔A实体、属性、实体集B实体、键、联系C实体、属性、联系D实体、域、候选区答案:C10.要保证数据库的数据独立性,需要修改的是〔A模式与外模式B模式与内模式C三级模式之间的两层映射D三级模式答案:C11.描述数据库全体数据的全局逻辑结构和特性的是〔A模式B内模式C外模式D全模式答案:A12.在数据库管理技术发展的3个阶段中,没有专门的软件对数据进行管理的阶段是〔I.人工管理阶段 II.文件系统阶段 III.数据库阶段AI 和 IIB只有 IICII 和 IIID只有 I答案:D13.下列四项中,不属于数据库系统特点的是〔A数据共享B数据完整性C数据冗余度高D数据独立性高答案:C14.应用数据库的主要目的是为了〔A解决数据保密问题B解决数据完整性问题C解决数据共享问题D解决数据量大的问题答案:C15.如果一个班只有一个班长,且一个班长不能同时担任其他班的班长,班和班长两个实体之间的联系属于〔。
《数据库理论与技术》复习题

《数据库理论与技术》期终考试复习题一、选择题:1.Chubby presents itself to clients as this service:a) Centralized mutual exclusion b) Hierarchical mutual exclusionc) Token-based mutual exclusion d) Contention-based mutual exclusion.2.Which statement best describes a client's interaction with Chubby?a) A client contacts any Chubby server, which then forwards the request to the appropriateserver in the Chubby cell.b) A client contacts any Chubby server, which can process the request since all Chubbyservers are replicated.c) A client contacts the Chubby master, which then forwards the request to the appropriateserver in the Chubby cell.d) A client contacts the Chubby master, which handles all client requests.3.By sending messages through Paxos, processes can ensure that concurrent messages become:a) Global time ordered multicasts. b) Totally ordered multicasts.c) Causally ordered multicasts. d) Unordered multicasts.4.Based on their vector timestamps, which event causally precedes (4, 2, 8, 5)?5.a) (3, 1, 7, 7) b) (5, 1, 6, 2) c) (4, 2, 8, 4) d) (4, 3, 8, 5)6.With Paxos, message sequence numbers are assigned by the:a) Acceptor b) Client c) Learner d) Proposer7.Paxos reaches agreement when:a)All proposers agree on a value to send to the acceptors.b)All acceptors agree to a proposed value.c)The majority proposers agree on a value to send to the acceptors.d)The majority of acceptors agree to a proposed value.8. A write-ahead log does NOT enable a process to:a) Undo changes in case of an abort. b) Record that a transaction has committed.c) Record the response that was sent to a vote in a commit protocol.d) Achieve higher performance by prefetching data.9.To abort a distributed transaction:a)At least one participant must vote to abort.b)The majority of participants must vote to abort.c)All of the participants must vote to abort.d)All live participants must vote to abort.10.The motivation for an eventual consistency model was:a)It is impossible to have highly available replicated data that is fully consistent in asystem that can survive network partitioning.b)Data inconsistencies are highly undesirable, so the primary focus should be on ensuringthat all replicas are consistent.c)Distributed commit protocols can never work reliably, so data is bound to becomeinconsistent on some participants.d)Data might be in an inconsistent state during the execution of transactions but will bemade consistent when they commit.11.In Bigtable, each server is responsible for serving tablets. A tablet is:a)A subset of rows and column families.b)A subset of rows but stores all column family data for those rows.c)A set of one or more column families but it stores all row data for those column families.d)Exactly one row and one column family.12.Differing from a distributed hash table, Bigtable:13.a) Can support replication for fault tolerance.14.b) Supports more than one primary key for looking up data.15.c) Can associate large amounts of data with a key.16.d) Sorts its data by the key and allows iteration over rows of sorted data.17.Which of these operations is most efficiently implemented on a large-scale GFS (GoogleFile System) system?18.a) Read one 1 TB file. b) Read 1 million 1 MB files.19.c) Write one 1 TB file. d) Write 1 million 1 MB files.20.The partitioning function in MapReduce21.a) Determines which shard will be assigned to a specific map worker.22.b) Filters out unnecessary input data prior to being processed by the map worker.23.c) Determines the division of available servers into map workers and reduce workers.24.d) Determines which reduce worker will process data associated with a particular key.25.Amazon Dynamo allows an administrator to add a greater load to a bigger server in thegroup by26.a) Configuring the client library to issue a higher percentage of its requests to that server.27.b) Configuring other servers to forward some percentage of their requests to the biggerserver.28.c) Using consistent hashing and giving a larger consecutive range of the hash space to theserver.29.d) Assigning more virtual nodes to that server.30.Which of the following is NOT a responsibility of a map worker in the MapReduceframework:a) Generate (key, value) pairs.b) Target (key, value) data for one of Rreduce workers.c) Partition original data into shards. d) Discard data of no interest.31. A key design principle of the Google cluster architecture is32.a) Merging is fast; break up databases into lots of pieces and use lots of processes, eachworking on a piece of the data.33.b) Minimize the number of phases in a task; create many replicas of a database and alloweach system full access to it without the need for sharing or locking.34.c) Minimize context switch overhead; machines are cheap and it's more efficient to devote anode to one task exclusively.35.d) Machines and software fail; run the same task redundantly in parallel to ensure successfulexecution.二、简答题:1. 考虑用二元联系(图1)对三元联系(图2)的表示: 图1图1图21) 分别给出图1中E ,A ,B ,C ,R A ,R B 和R C 的一个实例,这些实例不对应图2中A ,B ,C 和R 的任何实例;2) 更改图1中的ER 图,引入适当的约束以确保满足约束的E ,A ,B ,C ,R A ,R B 和RC 的任何实例都对应于A ,B ,C 和R 的一个实例;3) 更改以上的转化以表示在三元联系上的全参与约束;2. Suppose that we are using extendable hashing on a file that contains recordswith the following search-key values:2, 3, 5, 7, 11, 17, 19, 23, 29, 31,35,271) Show the extendable hash structure for this file if the hash function is h(x) =x mod 11 and buckets can hold three records.2) Show how the extendable hash structure of part 1) changes as the result ofeach of the following steps:a. Delete 11.b. Insert 15.c. Delete 31.d. Insert 25.3. The key-value store uses quorums for consistency. The total number of replicas,N, for a key, is fixed – however, N may be different for different keys. Each read has to access at least r replicas (and returns if all of them agree), while each write has to write to at least w replicas.For each of the following design choices, say whether it (by itself) does or does not guarantee strong consistency, i.e., one copy serializability?a. w=3, r=1b. w = 2N/3c. r+w = NA B E CR A R C R B B A R Cd. w = Ne. r + w > N/2f. r + w > 3N/2g. r + w > 3N/2, w > 2N/34.The following scenario is a distributed file system which spans multipledatacenters. There are several choices for how to handle network partitions that occur in between datacenters (given below). For each of these choices, tell me: if it violates consistency?a.Allow all partitions to process both reads and writes.b.Allow all partitions to process reads, but only one special partition(prechosen)to process writes.c.Allow only the partition which has at least a quorum number of servers(measured across all datacenters) to execute writes.d.Until partitions are repaired, allow only reads but no writes.e.Allow only partitions with a quorum of servers (measured across all datacenters) to execute writes and reads.mport’s Logical Clocks, among other things, help make inferences aboutconsistency of replicated data items operated upon concurrently. The following figure shows the time-line diagrams of three processes P, Q and R.a.Fill in the logical times for each event (a)–(o) in the three processes usingthe rules of local ordering, send/receive ordering and transitive closure.b.Assuming you are given only the logical times for each event in a process,answer the following True, False or Unknown questionsi.Event b happened before event a.ii.Events a, h and m happened concurrently.iii.Event n happened before event c.iv.Events d, k and n occur at the same time instant.v.Event g did not happen before event l.vi.Event o happened after event l.6.设某WEB内容缓存系统采用一致性哈希算法进行内容分发管理。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
《数据库理论与技术》复习题-2008小妖版1. 考虑用二元联系(图1)对三元联系(图2)的表示:图1图21) 分别给出图1中E ,A ,B ,C ,R A ,R B 和R C 的一个实例,这些实例不对应图2中A ,B ,C 和R 的任何实例;2) 更改图1中的ER 图,引入适当的约束以确保满足约束的E ,A ,B ,C ,R A ,R B 和RC 的任何实例都对应于A ,B ,C 和R 的一个实例; 3) 更改以上的转化以表示在三元联系上的全参与约束;解:1) 令 E = {e 1, e 2}, A = {a 1, a 2}, B = {b 1}, C = {c 1}, R A = {(e 1, a 1), (e 2,a 2)},Rb={(e1,b1)}, Rc={(e1,c1)};可以看出,由于元组(e2,a2)的原因,不存在任何实例对应于E,Ra,Rb,Rc 2) 如下图所示:通过引入E 和关系 Ra , Rb , Rc 之间的全部参与的约束条件,以便在 E 中的每个元组都和 A ,B ,C 有关系。
3) 假设A 全部参与关系R ,则在A 和Ra 之间引入全部参与约束4) 将 E 看作弱实体集,而将Ra,Rb,Rc 看作标志联系集。
如下图所示2. 分别判断下列图中G1和G2是否互模拟(bisimulation),并说明理由解: (1)在图中标出各点的状态,我们构造关系S={(P0,Q0),(P1,Q1),(P2,Q1),(P3,Q2),(P4,Q3)}可知G2可以模拟G1,下面我们讨论S +1={( Q0, P0),(Q1, P1),(Q1, P2),(Q2, P3),(Q3,P4)}abc ab cc G 1 G 2dd daa abccb G 1=G 2=是否可模拟,在G2中Q0有一个a 变换可对应到G1中2个变换,即(Q1,P1)∈S-1, (Q1,P2)∈S-1。
但Q1有两个变换b,c ,而在G1中公存在只有b 或只有c 的状态点,可知G1和G2不能互模拟。
(2)如图,标出各状态点,构造有关系S={(P0,Q0),(P1,Q1),(P1,Q2),(P2,Q3),(P2,Q4), (P3,Q5)},可知其中G1中的点均可由G2中的点模拟,下面我们考虑S +1={( Q0, P0),(Q1, P1),(Q2, P1),(Q3, P2),(Q4,P2),(Q5,P3)},可知同样其中G2中的点均可由G1中的点模拟,所以G1和G2互模拟。
3. 什么是可恢复调度?为什么要求调度的可恢复性?存在要求允许出现不可恢复调度的情况吗?说明理由。
答:假设在一个调度中,Tj 读取了Ti 写入的数据,Ti 在提交前发生故障,我们必须中止Tj 以保证事务地原子性。
若Tj 在Ti 出现故障后是可中止的,那么我们就称该调度是可恢复调度。
可恢复调度应满足:对于每个事务Ti 和Tj ,如果Tj 读取了由Ti 所写的数据项,则Ti 先于Tj 提交。
4. 设关系r1(A ,B ,C),r2(C ,D ,E)有如下特性:r1有200 000个元组,r2有45 000个元组,一块中可容纳25个r1元组或30个r2元组。
试估算以下每一种策略计算r1|><|r2所需存取的块数:1) 嵌套循环连接 2) 块嵌套循环连接 3) 归并连接 4) 散列连接解:r1需要8000个块,r2需要1500个块。
假设有一个存储器有M 页。
如果M>1500,那么使用平坦嵌套循环,通过1500+8000次磁盘存取就可以很容易的完成连接操作。
因此我们只考虑M<=1500的情况。
(a) 嵌套循环连接:使用r1作为外关系,我们需要进行200 000×1500+8000=300,008,000次磁盘存取。
如果r2是外关系,那么我们需要45 000×8 000+1 500=360 001 500次磁盘存取。
B . 块嵌套循环连接:如果r1是外关系,我们需要8000/(M 2)-⎡⎤⎢⎥×1500+8000次磁盘存取,如果r2是外关系,我们需要1500/(M-2)⎡⎤⎢⎥×8000+1500次磁盘存取。
5. 设关系r1(A ,B ,C),r2(C ,D ,E)和r3(E ,F),其主码分别为A ,C ,E 。
假设r1有1500个元组,r2有2500个元组,r3有1000个元组。
1) 试估计r1|><|r2|><|r3的大小;2) 给出一个有效计算r1|><|r2|><|r3的策略答:1)因为连接具有结合律和交换性,所以不管我们怎样连接r1,r2和r3,最终连接r1,r2和r3得到的结果都是一样的。
因此,我们只考虑基于((r1 r2)r3)连接策略下的大小。
因为C 为r2的关键字,所以连接r1和r2产生至多包含1500个元组的关系。
同样,把前面得到的结果和r3进行连接,将产生至多包含1500个元组的关系,因为E 为r3的关键字。
因此,最终关系最多包含有1500个元组。
2)计算这个连接的一个有效的策略是为关系r2上的属性C 和关系r3上的属性E 创建索引。
然后对于r1中的每个元组,我们按照下面锝 方法作:A .使用在C 上创建的索引,在r2中查找最多一个元组,这个元组与r1中的C 匹配。
B .使用在E 上创建的索引,在r3中查找最多一个元组,这个元组与r2中的E 值匹配。
6. 设一个嵌入式SQL 应用程序中80%的时间花在运行SQL 代码上,20%的时间花在运行主语言代码上。
如果只对SQL 代码实施了并行,那么可以期望得到多大的加速比?说明理由。
答:由于不能被并行话的部分占总运行时间的20%,所以可获得的加速比最多不会超过5。
7. 假设一个系统运行三种类型的事务:A 类事务以50/s 的速度运行,B 类事务以100/s 的速度运行,C 类事务以200/s 的速度运行。
假设系统所处理的事务中A 、B 、C 三类事务所占比例分别为30%,30%,40%。
1) 如果A 、B 、C 三类事务之间互不干扰,系统的平均事务吞吐量是多少?1) 什么因素会使不同类型事务之间产生相互干扰,导致计算出的平均事务吞吐量不准确?2) 如果不同类型事务之间相互干扰的因素非常复杂,那么用什么方法可以得到比较准确的平均事务吞吐量?答:1)91200%40*100%30*50%30*=++n n n n2)引起事务之间干扰的最重要的原因之一是封锁竞争。
在前面的例子中,假设事务A和事务B 都是更新事务,而事务C 是查询事务。
由于处理器和磁盘之间的速度不匹配,很可能会出现下面的情况:A 类型的一个事务持有一个“热”数据项的锁,并且在等待将其写道磁盘中来完成操作,在在这个时候B 类或C 类一个事务正在等待事务A 持有的封锁。
在这种情况下,一些CPU 循环就被浪费了。
因此,观察到的事物吞吐量会比计算出来的吞吐量要小。
相反,如果A 类型的事务和B 类型的事务是大量消耗磁盘资源的事务,而C 类型事务时大量消耗CPU 资源的事务,那么观察到的事物吞吐量将会比计算到吞吐量大。
封锁竞争也会导致死锁,在这种情况下一些事务将不得不被终止。
事务的终止和重启将会导致观察到的吞吐量比计算出来的吞吐量要小。
数据结构大小的限制,事务管理器事务记录函数花费时间的变化情况等因素都会导致观察到的吞吐量和计算出来的吞吐量之间的不同。
3)如果不同类型事务之间的相互干扰因素非常复杂,那么我们可以采用性能模拟的办法对系统得吞吐量进行测试。
首先需要建立模型,然后再模型上进行各种实验,可以通过改变不同的实验环境来估算出系统得平均吞吐量。
8.对于下列每一种任务,哪一种并行形式(查询间并行、操作间并行、操作内并行)可能是最关键的?说明理由。
1)提高一个执行许多小的查询的系统吞吐量;2)在磁盘和处理器数目都很大的情况下,提高一个执行少量大的查询的系统吞吐量;答:查询间并行指的是:不同的查询或不同的事务彼此并行地执行。
操作内并行指的是:我们可以通过并行的执行每一个运算,如排序,选择,投影,连接等,来加速一个查询速度。
操作间并行指的是:我们可以通过并行地执行每一个查询表达式中地多个不同的运算,来加快一个查询的处理速度。
通过上面的介绍,我们可以知道,对于a查询间并行;对于b,操作内并行。
9.给定如下数据图(Data Graph):试分别给出其DataGuide 图和1-Iindex索引图如图:PS:此图为我自己画的,不知道是否正确,有懂行的麻烦看看!10.For the DTD, XML, and XQUERY given below, answer the questions listednext.The Document Type Definition myfriend.dtd:< !ELEMENT myfriends (person*)>< !ELEMENT person (id, name?, cell-phone*, children?)>< !ELEMENT children (child*)>< !ELEMENT child (name,toys*)>< !ELEMENT name ( #PCDATA)>< !ELEMENT toys ( #PCDATA)>< !ELEMENT id ( #PCDATA)> ... ]< !ELEMENT employees (emp*)>< !ELEMENT emp (id, work-phone, (contact|address)>< !ELEMENT address (city,zip,street)>< !ELEMENT id ( #PCDATA)>]< !ELEMENT contact ( #PCDATA)> ... ]The XML Document friends.xml:<myfriends><person><id> 1 </id><name> ``jack'' </name><cellphone> 2222 </cellphone></person><person><id> 2 </id><cellphone> 3333 </cellphone><children> <child><name> c1 </name> </child><children> <child><name> c2 </name> <toys> t1 </toys> </child> <child> <name> c2 </name> </child> ... </children></person></myfriends>The XML Document employees.xml:<employees><emp><id> 1 </id><workphone> 9999 </workphone><contact> ``me'' </contact></emp><emp><id> 2 </id><workphone> 8888 </workphone><address> <city> c </city> <zip> z </zip> <street> s </street> </address> </emp></employees>The XQUERY expression:<contact-info>FOR $outer in (friends.xml)//person,LET $child := $outer/childrenWHERE ($outer/cellphone > 2000 )RETURN$outer/idFOR $inner IN (employees.xml)/employees/emp[id=$outer/id]RETURN{<contact>$outer/cellphone$child/child$inner/workphone$inner/address/city</contact>}</contact-info>1) List the XML output that the XQUERY expression would generate whenapplied to the given XML input documents.2) Design a relational schema to store the two given XML data files.3) List the SQL query that you would generate to execute the given XQUERYexpression on your relational database. State what final computations would remain to be done by the XQUERY processor beyond executing your SQLstatement, if any.解:1) <contact-info><id> 1 </id><contact><cellphone> 2222 </cellphone><workphone>9999</workphone></contact><id> 2 </id><contact><cellphone> 3333 </cellphone><child><name> c1 </name> </child><child><name> c2 </name> <toys> t1 </toys> </child><child> <name> c2 </name> </child><workphone>8888</workphone><city>c</city></contact></contact-info>2) person(pid, cellphone, name)child(cid, parentid, name)toy(tid, cid, toy_name)emp(pid, workphone, contact, city, zip, street)3) person(pid, name, cellphoneSet MultiSet(cellphones), ChildSet MultiSet(children))cellphones(cellphone)children(name, toySet MultiSet(toys))toys(toyname)emp(pid, workphone, contact, city, zip, street)4) select person.cellphone,array( select child.toy form childwhere child.parentid=person.pid) as child_array,emp.workphone, emp.cityfrom person, child, empwhere person.pid=emp.pid AND person.cellphone>200011.Suppose you have to represent the information about parts. Each part has a name(unique),and a textual description. Parts may be simple or complex. A simple part has a color but no children subparts. A complex part has a number of children subparts (which can be simple or complex), each of which may be repeated. (E.g.,a car has 4 wheels.) You can assume that each part can be a child subpart of atmost one other part (so each part, together with its subparts, can be viewed as a tree). Do not assume any fixed number of levels of part composition.1)Define the schema of XML documents containing part information usingDTDs.2)Give an example of a document instance which is valid under the DTDs.3)Write the following queries in XQuery:(a)f ind the names of all the yellow parts.(b)f ind all the parts that have at least 5 distinct children subparts.(c)f ind all the parts containing a descendant su bpart named “spoke"and not con taining a descendant subpart named “tire".ANSWER:1)<!DOCTYPE Parts[<!ELEMENT Parts(part)+><!ELEMENT Part(description, subpartinfo*|color))><!ATTLIST Partname ID #REQUIRED><!ELEMENT subpartinfo(part)><!ATTLIST subpartinfoname ID #REQUIRED><!ELEMENT qty (#PCDATA)><!ELEMENT name (#PCDATA)>]>2) <parts><part name=”bicycle”><subpartinfo><part name=”wheel”><subpartinfo><part name=”rim”><color>silver</color></part><qty> 1 </qty></subpartinfo><subpartinfo><part name=”spokes”><color>silver</color></part><qty> 40 </qty></subpartinfo><subpartinfo><part name=”tire”><color>black</color></part><qty> 1 </qty></subpartinfo></part><qty> 2 </qty></subpartinfo><subpartinfo><part name=”brake”><color>black</color></part><qty> 2 </qty></subpartinfo><subpartinfo><part name=”gear”><color>black</color></part><qty> 3 </qty></subpartinfo><subpartinfo><part name=”frame”><color>yellow</color></part><qty> 1 </qty></subpartinfo></part></parts>3)(a) for $p in //partwhere $p[color=”yellow”]return $p/@name(b) for $p in //partwhere count($p/subpartinfo)>=5return $p(c) for $p in //partWhere ($p//name=”sopke”)and(not($p//name=”tire”))Return $p12.Consider the relation PARTS, which has Part# as hash key and which includesrecords with the following Part# values: 2369, 3760, 5046, 4871, 5659, 2222, 1821, 1074, 7115, 1620, 2428, 3943, 4750, 3157, 6975, 4981, 9208. The hash function uses 8 buckets, numbered 0 to 7. Each bucket is one disk block and holds two records.1)Load these records into the file in the given order using the hash functionh1(K)=K mod 8. Calculate the average number of block accesses for a random retrieval on Part#.2)Now load the records into expandable hash files based on linear hashing. Startwith a single disk block, using the hash function h2(K)= K mod 2, and showhow the file grows and how the hash functions change as the records areinserted. Assume that blocks are split whenever an overflow occurs, and show the value of n at each stage.解:1)平均查找代价:(8+6*2+3+3+3)/ 17=1.712)13. Consider a hash-join of two relations R and S having B(R) = 1000 and B(S) =500. The values in R and S are skewed such that the hash function assigns three times as many tuples to even-numbered hash buckets as to odd-numbered buckets.1) How much memory would be required to perform the join in two passes? 2) What is the performance of the hash-join given the skewed hashing? 3) How would the performance of using the hash-join compare to using a sorted-merge algorithm?4) 解: 5) 1。