上海交通大学数据库原理陆朝俊复习.docx
数据库原理二复习、习题分析
问 题: (1) 事务的COMMIT语句和ROLLBACK语句各做什么事情? (2) COMMIT操作和检查点时的操作有什么联系? (3) 应该如何恰当协调这两种操作才有利于DB的恢复?
(1) 事务的COMMIT语句和ROLLBACK语句各做什么事情? 答:COMMIT语句表示事务执行成功地结束(提交),此时告诉系
πAC(F)={ A→C }
5.18 设有一个记录各个球队队员每场比赛进球数的关系模式 R(队员编号,比赛场次,进球数,球队名,队长名)
如果规定每个队员只能属于一个球队,每个球队只有一个队长。 ① 试写出关系模式R的基本FD和关键码。 ② 说明R不是2NF模式的理由,并把R分解成2NF模式集。 ③ 进而把R分解成3NF模式集,并说明理由。
二、本章的重点篇幅
(1)检查点机制的方法和恢复算法。(教材中P.175-176)
(2)并发操作带来的三个问题,封锁带来的三个问题,并发
调度的可串行化。
(教材P.177-179)
(3)SQL中完整性约束的实现,断言、触发器(SQL3)。
(教材P.185-191)
SQL Server 触发器的使用
(教材P.298-300)
设计概念模型(ER模型)
把ER模型转换成关系模型
硬件和 OS特征
物理设计
输出:完整的DB结构,
应用程序的设计准则。
运行和维护
设计DB物理结构(存储结构 和存储方法)
二、本章的重点篇幅 (1)教材中P163-165的转换规则和实例。 (2)教材中P159-160的ER模型实例。 三、要求掌握 (1)基本概念、定义、方法; (2)根据用户的需求,进行ER模型设计; (3)根据转换规则,将ER模型转换为关系模型。
上海大学数据库原理一 复习
联系:
•联系的元数: 相互联系的实体的个数。有一元联系、二元 联系、多元联系
•联系的连通词: 涉及到的实体集之间实体对应的方式。即 参加联系的实体的数目,分:一对一(1:1)、一对多 (1:N)、多对多(N:M) 联系的连通词也称为联系的性质
•联系的基数: 有两个实体集E1和E2,E1中的每个实体与 E2中有联系实体数目的最小值Min和最大值Max,称为 E1的基数,用(Min,Max )表示。
不能表示为:πSNO (SC÷πCNO(C))
第4章 关系数据库语言SQL
1.SQL的数据定义:SQL模式、基本表和索引的创建 和撤销,SQL提供的数据类型、主键外键定义。
2. SQL的数据查询:SELECT语句的格式,单表和多表查询,
基本表的联接操作,聚合和分组,集合操作。
3. SQL的数据更新:插入、删除和修改语句。
数据独立性定义 两级数据独立性: 物理数据独立性、逻辑数据独立性
5.数据库管理系统
DBMS的工作模式:
数据请求
低层指令
应用程序
DBMS
数据
数据
DB
(处理结果)
(查询结果)
用户访问数据的过程 :
应用程序
DB的系统缓冲区
DBMS
OS
DB
外模式
数 据
模式
字
典
内模式
DBMS的主要功能:
1.数据库的定义功能 2.数据库的操纵功能 3.数据库的保护功能 4.数据库的维护功能 5. 数据字典
2. 数据联系的描述 联系的元数:与一个联系有关的实体集的个数 联系的类型: 一对一(1:1) 一对多(1:n) 多对多(m:n)
3. 数据模型的概念: 表示实体类型及实体间联系的模型 概念数据模型(对现实世界的第一层抽象)(E-R模型)
2022年上海交通大学软件工程专业《数据库原理》科目期末试卷B(有答案)
2022年上海交通大学软件工程专业《数据库原理》科目期末试卷B(有答案)一、填空题1、数据管理技术经历了______________、______________和______________3个阶段。
2、有两种基本类型的锁,它们是______和______。
3、数据仓库主要是供决策分析用的______,所涉及的数据操作主要是______,一般情况下不进行。
4、数据库系统是利用存储在外存上其他地方的______来重建被破坏的数据库。
方法主要有两种:______和______。
5、在SQL Server 2000中,某数据库用户User在此数据库中具有对T 表数据的查询和更改权限。
现要收回User对T表的数据更改权,下述是实现该功能的语句,请补全语句。
_____UPDATE ON T FROM User;6、完整性约束条件作用的对象有属性、______和______三种。
7、在SQL语言中,为了数据库的安全性,设置了对数据的存取进行控制的语句,对用户授权使用____________语句,收回所授的权限使用____________语句。
8、关系系统的查询优化既是关系数据库管理系统实现的关键技术,又是关系系统的优点。
因为,用户只要提出______,不必指出 ______。
9、某事务从账户A转出资金并向账户B转入资金,此操作要么全做,要么全不做,为了保证该操作的完整,需要利用到事务性质中的_____性。
10、以子模式为框架的数据库是______________;以模式为框架的数据库是______________;以物理模式为框架的数据库是______________。
二、判断题11、关系是一张二维表。
()12、在关系模式中,主码和候选码可以有多个。
()13、SQLServer有两种安全性认证模式:WindowsNT和SQLServer。
()14、在CREATEINDEX语句中,使CLUSTERED来建立簇索引。
上海交大网络数据库原理与应用第一次作业
(1)找出所有供应商的姓名和所在城市。
SELECT SNAME,CITY FROM S(2)找出所有零件的名称、颜色、重量。
SELECT PNAME,COLOR,WEIGHT FROM P(3)找出使用供应商S1所供应零件的工程号码。
SELECT DIST JNO FROM SPJ WHERE SNO='S1'(4)找出工程项目J2使用的各种零件的名称及其数量。
SELECT PNAME,QTY FROM SPJ,PWHERE P.PNO=SPJ.PNO AND SPJ.JNO='J2'(5)找出上海厂商供应的所有零件号码。
SELECT PNO FROM SPJ,S WHERE S.SNO=SPJ.SNO AND CITY='上海'(6) 找出使用上海产的零件的工程名称。
SELECT JNAME FROM SPJ,S,JWHERE S.SNO=SPJ.SNO AND S.CITY='上海' AND J.JNO=SPJ.JNO(7)找出没有使用天津产的零件的工程号码。
注意: SELECT DISP JNO FROM SPJ WHERE JNO NOT IN (SELECT DIST JNO FROM SPJ,S WHERE S.SNO=SPJ.SNO AND S.CITY='天津') 适用于JNO是唯一或不唯一的情况.注意: SELECT DIST JNO FROM SPJ,S WHERE S.SNO=SPJ.SNO AND S.CITY<>'天津'适用于JNO是唯一的情况(8)把全部红色零件的颜色改成蓝色。
UPDA TE P SET COLOR='蓝' WHERE COLOR='红'(9)由S5供给J4的零件P6改为由S3供应。
UPDA TE SPJ SET SNO='S3' WHERE SNO='S5' AND JNO='J4' AND PNO='P6'(10)从供应商关系中删除供应商号是S2的记录,并从供应情况关系中删除相应的记录。
上海交通大学-数据库原理-陆朝俊-课件18XML
Lu Chaojun, SJTU
2
Semistructured-Data Model
• Provides flexible conceptual tools to describe the real world.
• It is a kind of data model that – is suitable for integration of heterogeneous databases, and – serves as the underlying model for XML that are being used to share of information on the Web.
manf
manf
A.B. name
servedAt
M’lob
prize
year 1995
award Gold
name
addr
Joe’s
Maple
Lu Chaojun, SJTU
6
Application: Info. Integration
• Problem: related data exists in many places, and needs be accessible as if they were one DB.
• Root node has no arcs entering and represents the entire database.
• Label on arc: indicates how the target node relates to the source node.
– No restriction on labels: representing attributes or relationships.
复习课1上海交通大学继续教育学院课件
R->next->prior=R->prior; free(R);
(2)
p->next->prior=S; P-
>next=S;
(2) S->next=P; S->prior=P->prior;
(4) R=P->prior; P->prior=R->prior; R ->prior ->next=R->next; free(R);
SElemType *base; SElemType *top; int stacksize; }SqStack; 其中stacksize表示栈当前可以使用的最大容量。base为栈底, top为栈顶。栈顶指针指向栈顶元素的下一个位置(即下次压栈 时元素所放的位置)
复习课1上海交通大学继续教育学院
• 顺序栈的结构
• 定义栈结构
Typedef struct stack_node
S
{ elemtype data;
8
栈顶
struct stack_node *next;
7
} STKPTR;
STKPTR *stk;
问:在这里为什么没有用到top指针?这样对栈结构
的定义有否影响?
2
1 ^ 栈底
复习课1上海交通大学继续教育学院
• 存储单元不要求连续:物理结构不反应逻辑结构 • 不可以随机存取,但插入和删除方便 • 需要两个域:一个表示数据本身;一个表示数据元素间的先
后关联。——一个结点。 • 结点中表示关联的部分为指针域,内部存放指针或链。n个
结点链接成一个链表。
复习课1上海交通大学继续教育学院
线性链表
• 线性链表的物理存储结构
上海交通大学数据库原理陆朝俊复习.docx
上海交通大学数据库原理陆朝俊复习.docx ERf \ r g/ \ If we translate this diagram to relations in the normal way for E/R diagrams described in the textbook, which relation schema would not be in the resulting database schema?(A)E(a,c,b) (B) S(a,c£g) (C) F(c,d) (D) R(a,c)If we instead used the “object-oriented" approach to translating this E/R diagram to relations, how many relation schema would be different (when compared to the E/R-to-relations translation), either in their schema, or their set of tuples, or both?(A)1 (B) 2 (C) 3 (D) 4Convert the following E/R diagram (with details omitted) to a relational database schema using the object-oriented method?How many relation schemas will be produced? (Assume that each entity set has its own special attributes.)B CD(A) 1 (B) 4 (C)5 (D)6Relational TheoryGiven a relation R(A,B,C,D,E) and FDs AB T CE,B T D,and D T E, which of the following FD's can not be inferred?(A)AD T CE (B) BC T D (C) AB T A (D) B T EGiven a relation R(A,B,C,D) with FD: A T BC, which of the following MVD's can not be inferred?(A)A TT EC(B)A TT B(C)A TT BD(D)None of the above.Suppose we have a relation R(A,B,C,D,E) and the FD's A T DE,D T B,and E—>C. If we project R (and therefore its FD,s) onto schema S(A,B,C),what is true about the key(s) for S?(A)Only ABC is a key(B)Only A is a key(C)Only DE is a key(D)A5 B, and C are each keysSuppose we are given a relation schema R(A,B,C,D,E) with functional dependencies A T B,BC T D and E T C. If we project R onto S(B,C,D,E),which of the following functional dependencies holds in S and is not a BCNF violation for S?(A)BC T D (B) BE T D (C) B T E (D) E T CSuppose that R(A,B,C,D) satisfies MVD:A TT B and it is known that R has tuples (al,bl,cl,dl), (al,b2?c25d2)? and (a2,bl,cl,d2)?How many tuples must R have at least?(A)3 (B)4 (C)5 (D)6Relational algebra and DatalogIn the following question, assume R and S are bags, and the operators are bag operators.Q1:(RU S)-(RAS)Q2: (S-R) U (R-S)(A)QI and Q2 produce the same answer.(B)The answer to QI is always contained in the answer to Q2.(C)The answer to Q2 is always contained in the answer to QI.(D)QI and Q2 produce different answers.Given relations P(A,B,C) and Q(C,D),which of the followingrelational algebra expressions is equivalent to this Datalog rule: Answer(x,w) P(x,y,z) AND Q(y,w) AND x<y< bdsfid="120" p=""></y<>(A)兀P.A,Q.D(6.A<="" °°p.c="Q.C">(B)兀P.A,Q.D(6.A<="" x="">(C)兀P.A,Q.D(6.A<="">(D)兀P.A,Q.D(6.A<="">SQLQI: SELECT DISTINCT a FROM R WHERE b> 10;Q2: SELECT a FROM R WHERE b> 10 GROUP BY a;(A)QI and Q2 produce the same answer.(B)The answer to QI is always contained in the answer to Q2.(C)The answer to Q2 is always contained in the answer to QI.(D)QI and Q2 produce different answers.Consider the following two SQL queries on relations R(a,b) and S(c):QI: SELECT a FROM RWHERE b > ALL (SELECT c FROM S);Q2: SELECT a FROM RWHERE b > ANY (SELECT c FROM S);(A)Q1 and Q2 always produce the same answer.(B)The answer to QI is always contained in the answer to Q2?(C)The answer to Q2 is always contained in the answer to QI.(D)None of the above.Given R(A,B)={('a;10),('b;20),('c',30)}, and execute the following three statements. What is the result of the last statement?create view V as select A from R where B>10;insert into V values('cT);select count(*) from V;(A)1 (B) 2 (C) 3 (D) 4Given a relation R(x) and two queries as follows:QI: SELECT x FROM R;Q2: (SELECT x FROM R) UNION (SELECT x FROM R);(A)QI and Q2 produce the same answer.(B)The answer to QI is always contained in the answer to Q2.(C)The answer to Q2 is always contained in the answer to QI.(D)None of the above.In the 3-valued logic used by SQL, suppose x has the value NULL and y is TRUE, the result for (x > 1) OR y is:(A)FALSE (B) UNKNOWN (C) TRUE (D) NULLConsider the following two SQL queries on relations R(a?b) and S(b9c):QI: (RNATURAL FULL OUTER JOIN S)UNION(R NATURAL JOIN S);Q2: (R NATURAL LEFT OUTER JOIN S)UNION(R NATURAL RIGHT OUTER JOIN S);(A)QI and Q2 produce the same answer.(B)The answer to QI is always contained in the answer to Q2.(C)The answer to Q2 is always contained in the answer to QI.(D)QI and Q2 produce different answers.Suppose that relation R(A,B) has 100 tuples and S(B,C) has 50 tuples. The number of tuples in R NATURAL LEFT OUTER JOIN S is at most:(A) 50 (B) 100 (C) 150 (D) 5000Assume that a relation R(a,b) has no NULL's but may have duplicates? Compare the following two queries:QI: SELECT count(*) FROM R GROUP BY a;Q2: SELECT count(b) FROM R GROUP BY a;(A)QI and Q2 produce the same answer.(B)The answer to QI is always contained in the answer to Q2.(C)The answer to Q2 is always contained in the answer to QI.(D)QI and Q2 produce different answers.In the following, the results of QI and Q2 should be taken to be the result of the final SELECT * FROM R. Assume that the schema of relation R is R(a,b).QI: DELETE FROM R WHERE a=10;INSERT INTO R VALUES(10,5);SELECT * FROM R;Q2: UPDATE R SET b=5 WHERE a=10;SELECT * FROM R;(A)QI and Q2 produce the same answer.(B)The answer of QI is contained in the answer of Q2.(C)The answer of Q2 is contained in the answer of QI.(D)QI and Q2 produce different answers.IntegritySuppose we have the following table declarations: CREATE TABLE A (w INT PRIMARY KEY); CREATE TABLE B (x INT PRIMARY KEYREFERENCES A(w) ON DELETE SET NULL); CREATE TABLE C (y INT REFERENCES A(w)); CREATE TABLE D (zl INT REFERENCES B(x) ON DELETE SET NULL, z2 INT REFERENCES A(w) ON UPDATE CASCADE);Consider the following scripts: (1)DELETE FROM C; DELETE FROM B; DELETE FROM A; DELETE FROM D;(2)DELETE FROM C; DELETE FROM D; DELETE FROM A; DELETE FROM B;(3)DELETE FROM B; DELETE FROM C; DELETE FROM D;DELETE FROM A;Which of the above scripts will empty all four tables, without error?(A)⑶ only(B)(1) only(C)(2) and (3) only(D)(1) and (3) onlySuppose R is declared asCREATE TABLE R (a INT REFERENCES S(b)ON UPDATE CASCADE); Which of the following modifications on S will never be rejected for violating the referential integrity constraint?(I)DELETE FROM S;(II)UPDATE S SET b = 10;(III)INSERT INTO S(b)VLAUES(IO);(A)(I)(H)(B)(11)(111)(C)(i)(m)(D)None of (1),(11)9(111)Suppose we want to enforce the FD A T B on R(A,B,C) using triggers. Consider the following operations. For which of them do we need to create a trigger on R?(A)delete on R(B)update of C on R(C)insert on R(D)All of the aboveSuppose we want to enforce the MVD: A TT B on R(A,B,C) using triggers? Consider the following operations. For how many of them should we create a trigger?(1)INSERT ONR(2)DELETE ON R(3)UPDATE OF A ON R(4)UPDATE OF B ON R(5)UPDATE OF C ON R(A) 2 (B) 3 (C) 4 (D) 5Suppose you find the following statement in a program:... FETCH FROM myCursor INTO myVar ... Then the program may be written in:(A)Embedded SQL only(B)SQL/PSM only(C)Both Embedded SQL and SQL/PSM(D)None of the aboveTransactionAssume that we have a relation Employee(TD, salary) where ID is the key,and that Employee initially has two tuples (A,20) and (B,30). Consider the following two concurrent transactions: Tl: BEGIN TRANSACTION;UPDATE Employee SET salary = 2*salaryWHERE ID =,A,;UPDATE Employee SET salary = salary+10WHERE ID = W;COMMIT;T2: BEGIN TRANSACTION;SELECT AVG(salary) AS sail FROM Employee;SELECT AVG(salary) AS sal2 FROM Employee; COMMIT; Suppose that T1 and T2 execute at isolation level SERIALIZABLE and READ COMMITTED respectively, which of the following is an impossible pair of values for sail and sal2 returned by T2?(A)(35,40)(B)(40,40)(C)(25,25)(D)(25,40)PrivilegeSuppose user A is the owner of relation R(a,b). The following sequence of grants and revocation occurs:A: GRANT update on R to BA: GRANT update(a) on R to C WITH GRANT OPTION C: GRANT update(a) on R to B WITH GRANT OPTION A: REVOKE update(a) on R FROM C CASCADE Which of the following statement can user B do?(I)UPDATE R SET a=a+l;(II)GRANT update on R to C;(III)SELECT * FROM R;(A)only (I)(B)(1)(11)(C)(1)(11)(111)(D)None of (1)(11)(111)OO/OR Consider the following ODL declarations:class X (key A,B){ attribute integer A; attributeinteger B; relationship Y R1 inverse Y::R2; }; };class Y (key C) { attribute integer C; attribute integer D; relationship Set R2 inverse X::R1;Which of the following relation schemas are produced according to the standard translation in the textbook?(A)X(A,B) and Y(A9C5D)(B)X(A,B,C) and Y(C,D)(C)X(A,B) and Y(C,D)(D)X(A,B),Y(C,D) and R(A,B,C)Datalog/RecursionThe following queries are recursive Datalog, and as for all Datalog queries, the result is a set, not a bag.QI: Path(x9y) <- Arc(x?y)Path(x,y) <- Path(x?a) AND Path(a?b) AND Path(b,y)Q2: Path(x,y) <- Arc(x,y)Path(x,y) <- Path(x,z) AND Path(z,y)(A)Q1 and Q2 produce the same answer.(B)The answer to QI is always contained in the answer to Q2.(C)The answer to Q2 is always contained in the answer to QI.(D)QI and Q2 produce different answers.Given a relation R(A) = {1,2,3}? Consider the following query that involves a recursively defined relation P(X,Y):WITH RECURSIVE P(X,Y) AS(SELECT A AS X, A+l AS Y FROM R)UNION(SELECT COUNT(*) AS X,MAX(Y) AS Y FROM P)SELECT COUNT(*) FROM P;What value is in the result of this queiy?(A) 3 (B) 4 (C) 5 (D) None of the aboveXMLConsider the following XML DTD:]>How many elements are there in the smallest XML document (i.e.?a document containing the fewest possible elements) that conforms to the above DTD? Note that text values are not elements.(A) 3 (B)4 (C)5 (D)6 Assume that the XML document in file "XYZ.xml,,conforms to the following DTD:VELEMENT A(B*, C*)>]>Consider the following two queries in XQuery:QI: for $x in doc("XYZ.xml”)/A/Breturn $xQ2: let $x := doc(“XYZ.xml J $y := $x/A/Breturn $y(A)QI and Q2 produce the same answer.(B)The answer to QI is always contained in the answer to Q2.(C)The answer to Q2 is always contained in the answer to QI.(D)QI and Q2 produce different answers.。
数据库原理与应用试卷网本05级计算机20080610(B卷答案修改)-1
A.外模式、概念模式和内模式B.关系模型、网状模型、层次模型C.实体、属性和联系D.数据结构、数据操作和数据约束条件【B】7.要保证数据库物理数据独立性,需要修改的是()A.模式B.模式与内模式的映射C.模式与外模式的映射D.内模式【A】8.三级模式间存在两种映射,它们是()。
A.外模式与模式间,模式与内模式间B.子模式与内模式间,外模式与内模式间C.子模式与外模式间,模式与内模式间D.模式与内模式间,模式与模式间【A】9.关系模型中,表示实体间n:m联系是通过增加一个()。
A.关系实现B.属性实现C.关系或一个属性实现D.关系和一个属性实现【C】10.对关系数据库来讲,下面哪种说法是错误的()A.每一列的分量是同一种类型数据,来自同一个域。
B.不同列的数据可以出自同一个域。
C.行的顺序可以任意交换,但列的顺序不能任意交换。
D.关系中的任意两个元组不能完全相同。
【C】11.如何构造出一个合适的数据逻辑结构是()主要解决的问题。
A.关系数据库优化B.数据字典C.关系数据库规范化理论D.关系数据库查询【D】12.保险公司有多个投保客户,每个投保客户在多个保险公司投保,保险公司与投保客户之间是()。
A.一对一的联系B.一对多的联系C.多对一的联系D.多对多的联系【A】13.五种基本关系代数运算是()A.∪,—,×,π和σB.∪,—,∞,π和σC.∪,∩,×,π和σD.∪,∩,∞,π和σ【B】15.关系数据库管理系统存储与管理数据的基本形式是()。
A.关系树B.二维表C.结点路径D.文本文件【C】14.关系数据库中有三种基本操作,将两个关系中具有共同属性的元组连结到一起,构成新表的操作称为()。
A.选择B.投影C.连结D.扫描【B】15.关系数据库中有三种基本操作,从表中取出满足条件的属性成分的操作称为()。
A.选择B.投影C.连结D.扫描【A】16.关系数据库中有三种基本操作,从表中取出满足某种条件的元组的操作称为()。
数据库原理课后习题及解答(常用版)
数据库原理课后习题及解答(常用版)(可以直接使用,可编辑完整版资料,欢迎下载)《数据库原理》课后习题及解答课后习题:第一章第二章第三章第四章第五章第六章第七章第八章第九章习题答案:第一章第二章第三章第四章第五章第六章第七章第八章第九章第一章概论1.试解释下列术语:数据库;数据库管理系统;数据库系统2.试述数据库管理系统的组成内容。
3.试比较文件系统与数据库系统的异同。
4.什么叫数据的物理独立性与逻辑独立性?并说明它的重要性。
5.试述数据库系统的优点。
6.什么叫数据的冗余与数据的不一致性?7.什么叫数据库管理员?他的主要工作是什么?8.试述数据库系统发展的几个阶段。
返回第一章答案第二章数据模型1.什么叫数据库模型,它分哪几种类型?2.试区别数据模型与数据模式。
3.什么叫数据模式,它分哪三级?4.试述数据模型四个世界的基本内容。
5.试介绍E-R模型,EE-R模型及面向对象模型、谓词模型,并各举一例说明之。
6.层次网状模型有什么特点?并各举一例说明之。
7.试比较层次、网状、关系模型之优缺点。
8.试说明关系模型的基本结构与操作。
9.目前流行的关系型数据库管理系统,有哪些你比较熟悉,试介绍其特点。
10.你认为“数据模型”在整个数据库领域中是否有重要作用和地位,试详细说明之。
11.一图书馆借阅书刊,请你画出书刊、读者及借阅三者间的E-R模型。
12.一人事档案中,有干部、职工,干部又有高级干部与一般干部,请用EE-R模型画出他们之间关系。
13.试述物理模型的主要内容。
14.试叙述四个世界的转化关系。
15.请你比较四种数据模型的异同。
返回第二章答案第三章关系数据库系统1.试述关系数据库系统的优点。
2.试述关系型的12条标准,并说明FOXBASE为何是半关系型的。
3.关系代数与关系演算的表示能力是否相同?试证明之。
4.从关系模型的数学表示中,你是否认为网状与层次模型也可以用数学方法表示?试说明理由。
5.设有如图3-1所示的医院组织。
数据库原理总复习题.doc
数据库原理总复习题一、填空题1.SQLServer数裾库应用的处理过程分布在_客广机(或客广端)________ 和服务器上。
2.SQL Server提供了动态的A我管理机制,能够A动增大或缩小数据库所占用的_硬盘平间_。
7.SQL Server客户机传递到服务器上的一组完整的数裾和SQL语句称为_批处理__。
9.函数LEFT(4abcdef’,2)的结果是 ______ ’ab’。
10.SQL Server 屮的整数类型包拈___ bigint、int、smallint、tinyint (次序尤先O 四种。
11.Microsoft SQLServer2005是运行在_____ windows ______ 操作系统平台上的、逻辑模型为_关系 ____ 型数据库管理系统。
12.SQL Server将数裾组织到用户可以看见的_逻辑组件__________ ,而在磁盘上则作为操作系统文件实现。
13.如果希塑修改数据库的名字,可以使用的系统存储过程是_sp_rename db_。
14.数拋库备份和恢S的Transact-SQL语句分别是____ Backup Database ______ 和 ___ R estore Database _____ c15.找回被删除表的惟一方法是事先做好数裾库的_备份_工作。
16._索引_是一种常用的改善数据库性能的技术。
17.索引会影响对基木表的_插入、删除、修改_等操作的速度。
18.聚集索引与非聚集索引相比,杏询速度要_快_。
19.SQL Server中为局部变量赋值的语句是____ SELECT ____ 和 ____ S ET _____ 。
20.使川create database命令定义一个数据库,包括定义 ___ 数据 _____ 文件和 ____ 円志 ___文件两个部分。
21.基本表中的记录数越_多_,每条记录占用的字节数越_多_时,使用索引就越有利。
《数据库原理》复习纲要.docx
《数据库原理》复习纲要前言1.本门课程极具重要性,近几年的大专本科院校的计算机专业毕业设计论题十题有八题与数据库有关2.负责这门课考试的南邮老师说了:考试内容在模拟练习册中决不会占50%,故要求同学根据本提纲好好复习好课本重点内容3.每个教学点我都留下了一套教学光盘(共4张)以上,该光盘为东南大学《数据库原理》远程教学讲课光盘,之前我曾通过关系找来清华大学、中山大学、东南大学等多所院校远程教学光盘,经比较,认为东南大学的讲得较浅白,也较合适我们这次考试要求。
因此希望没能参加听课的同学能刻录一份回家好好看看。
惠州的可以找上一届李育权同学借盘刻录湛江的可找上一届林伟权、许强同学借盘刻录增城的请找朱运师老师拷贝,最好带个2G以上的移动硬盘去,因为内容拷在朱老师的电脑上,没有光盘使用光盘前请先安装光盘上的Tplayer文件才能正确播放光盘教学内容其中最一个光盘还带有课本与练习册的扫描图,课本中凡有用铅笔划了或作个记号均为考试要点,练习册的两份模拟题答案。
4.以下分三个部份列出本次复习重点第一部份书本本书第1-4章最为重点,占考试比例60-70%o第5-6章为次重点,约占考试比例20%o第7-8章更次重点占考试比例10% O以下P1代表书本第一页,P3代表书本第三页第一章一、P1数据库管理技术的发展经过那三个阶段:人工管理阶段、文件系统阶段、数据库阶段.二、P3什么是逻辑数据独立性(P3最后一段)三、P5 DB是:数据库、DBMS是数据库管理系统、DBS数据库系统数据描述三个领域:现实世界、信息世界、机器世界四、P5-P6什么是实体、实体集、属性、实体标识符、字段、记录、文件、关键码五、P7 6种物理存储介质的特点六、P8位、字节、字、块、桶、卷七、P8实体的联系有那两类?两个不同实体的三种情况:1:1 1:N M:N八、P10会画实体联系模型(ER模型,ER图的四个基本成份,理解例1.1P13理解例1.4 结合P143 会ER模型向关系模型转换(必考内容)(可参考东南大学课件05.csf第2分钟,46.csf第13分钟43.csf第25分钟)九、P18数据独立性是指应用程序和数据之间的相互独立,不受影响。
上海交通大学 数据库原理 陆朝俊 课件 课程设计指导
需求分析(续)
II. 系统将包含的信息 A. 每个学生或教师的信息 B. 学生的学业记录
1. 已完成课程及选修学期和分数 2. 本学期成功注册的课程 3. 以后学期的登记课程
C. 课程信息
1. 课程名称,代码,学时学分,…… 2. 允许注册的人数,实际注册人数 3. 上课时间和地点 ……
需求分析(续)
1. 成功登记信息 2. 登记人数超过限定 3. 已登记其他在同一时段的课程 ……
C. 分数登记:教师登记或改动学生在某门已完 成课程的分数
需求分析(续)
V. 系统描述 A. 客户/服务器体系结构 B. 用户界面是图形化的,易于使用 C. 关系型DBMS
总体设计
I. 根据需求分析,设计系统总体框架。 SCIM包括登录模块、学生基础信息管理模 块、课程基础信息管理模块、选课注册 模块、教师登录成绩模块、… 各模块具体功能如下:… II. 系统功能结构图
《数据库系统原理》 课程设计指导
目的
• 加深理解、掌握并巩固《数据库系统原理》课 程中所学到的基本概念、基本原理和基本技术; • 综合应用所学到的关于数据库系统的一般原理 和技术,以及其他课程的有关知识,来设计、 实现一个以数据库为核心的应用软件系统; • 培养分析问题、解决问题的能力,进一步提高 进行大型程序设计的能力;
任务
• 选择一个应用领域或组织,设计、实施 数据库,开发基于数据库的、具有较完 善功能的、方便最终用户使用的应用程 序。
要求
按照软件工程规范的要求进行数据库设计 和应用程序开发。具体要求如下: • 对特定应用领域进行用户需求分析,包 括数据需求和功能需求,形成需求文档; • 利用E/R方法为特定应用领域设计概念模 式,再转换成关系模式(RDB),形成 数据库设计文档;
(完整word版)数据库原理期末考试复习题及答案(word文档良心出品)
数据库原理-期末考试复习题一一、单项选择题(本大题共20小题,每小题2分,共40分)在每小题列出的四个备选项中只有一个是符合题目要求的,请将其代码填写在题后的括号内。
错选、多选或未选均无分。
1. 数据库系统的核心是( B )A.数据库B.数据库管理系统C.数据模型D.软件工具2.下列四项中,不属于数据库系统的特点的是(C )A.数据结构化B.数据由DBMS统一管理和控制C.数据冗余度大D.数据独立性高3.概念模型是现实世界的第一层抽象,这一类模型中最著名的模型是( D )A.层次模型B.关系模型C.网状模型D.实体-联系模型4.数据的物理独立性是指( C )A.数据库与数据库管理系统相互独立B.用户程序与数据库管理系统相互独立C.用户的应用程序与存储在磁盘上数据库中的数据是相互独立的D.应用程序与数据库中数据的逻辑结构是相互独立的5.要保证数据库的逻辑数据独立性,需要修改的是( A )A.模式与外模式之间的映象B.模式与内模式之间的映象C.模式D.三级模式6.关系数据模型的基本数据结构是(D )A.树B.图C.索引D.关系7.有一名为“列车运营”实体,含有:车次、日期、实际发车时间、实际抵达时间、情况摘要等属性,该实体主码是( C )A.车次B.日期C.车次+日期 D.车次+情况摘要8.己知关系R和S,R∩S等价于( B )A. (R-S)-SB. S-(S-R)C.(S-R)-RD. S-(R-S)9.学校数据库中有学生和宿舍两个关系:学生(学号,姓名)和宿舍(楼名,房间号,床位号,学号)假设有的学生不住宿,床位也可能空闲。
如果要列出所有学生住宿和宿舍分配的情况,包括没有住宿的学生和空闲的床位,则应执行( A )A. 全外联接B. 左外联接C. 右外联接D. 自然联接10.用下面的T-SQL语句建立一个基本表:CREATE TABLE Student(Sno CHAR(4) PRIMARY KEY,Sname CHAR(8) NOT NULL,Sex CHAR(2),Age INT)可以插入到表中的元组是( D )A. '5021','刘祥',男,21B. NULL,'刘祥',NULL,21C. '5021',NULL,男,21D. '5021','刘祥',NULL,NULL11. 把对关系SPJ的属性QTY的修改权授予用户李勇的T-SQL语句是( C )A. GRANT QTY ON SPJ TO '李勇'B. GRANT UPDATE(QTY) ON SPJ TO '李勇'C. GRANT UPDATE (QTY) ON SPJ TO 李勇D. GRANT UPDATE ON SPJ (QTY) TO 李勇12.图1中( B )是最小关系系统A B C D图113.关系规范化中的插入操作异常是指 ( D )A.不该删除的数据被删除B.不该插入的数据被插入C.应该删除的数据未被删除D.应该插入的数据未被插入14.在关系数据库设计中,设计关系模式是数据库设计中( A )阶段的任务A.逻辑设计B.物理设计C.需求分析D.概念设计15.在E-R模型中,如果有3个不同的实体型,3个m:n联系,根据E-R模型转换为关系模型的规则,转换后关系的数目为( C )。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
ERf \ r g/ \ If we translate this diagram to relations in the normal way for E/R diagrams described in the textbook, which relation schema would not be in the resulting database schema?(A)E(a,c,b) (B) S(a,c£g) (C) F(c,d) (D) R(a,c)If we instead used the “object-oriented" approach to translating this E/R diagram to relations, how many relation schema would be different (when compared to the E/R-to-relations translation), either in their schema, or their set of tuples, or both?(A)1 (B) 2 (C) 3 (D) 4Convert the following E/R diagram (with details omitted) to a relational database schema using the object-oriented method・How many relation schemas will be produced? (Assume that each entity set has its own special attributes.)B CD(A) 1 (B) 4 (C)5 (D)6Relational TheoryGiven a relation R(A,B,C,D,E) and FDs AB T CE,B T D,and D T E, which of the following FD's can not be inferred?(A)AD T CE (B) BC T D (C) AB T A (D) B T EGiven a relation R(A,B,C,D) with FD: A T BC, which of the following MVD's can not be inferred?(A)A TT EC(B)A TT B(C)A TT BD(D)None of the above.Suppose we have a relation R(A,B,C,D,E) and the FD's A T DE,D T B,and E—>C. If we project R (and therefore its FD,s) onto schema S(A,B,C),what is true about the key(s) for S?(A)Only ABC is a key(B)Only A is a key(C)Only DE is a key(D)A5 B, and C are each keysSuppose we are given a relation schema R(A,B,C,D,E) with functional dependencies A T B,BC T D and E T C. If we project R onto S(B,C,D,E),which of the following functional dependencies holds in S and is not a BCNF violation for S?(A)BC T D (B) BE T D (C) B T E (D) E T CSuppose that R(A,B,C,D) satisfies MVD:A TT B and it is known that R has tuples (al,bl,cl,dl), (al,b2?c25d2)? and (a2,bl,cl,d2)・How many tuples must R have at least?(A)3 (B)4 (C)5 (D)6Relational algebra and DatalogIn the following question, assume R and S are bags, and the operators are bag operators.Q1:(RU S)-(RAS)Q2: (S-R) U (R-S)(A)QI and Q2 produce the same answer.(B)The answer to QI is always contained in the answer to Q2.(C)The answer to Q2 is always contained in the answer to QI.(D)QI and Q2 produce different answers.Given relations P(A,B,C) and Q(C,D),which of the following relational algebra expressions is equivalent to this Datalog rule: Answer(x,w) P(x,y,z) AND Q(y,w) AND x<y(A)兀P.A,Q.D(6.A<P.B(P °°P.C=Q.C Q))(B)兀P.A,Q.D(6.A<Q.C and P.C=Q.C(? X Q))(C)兀P.A,Q.D(6.A<P.C(P)00 Q)(D)兀P.A,Q.D(6.A<Q.C(P°°P.B=Q.C Q))SQLQI: SELECT DISTINCT a FROM R WHERE b> 10;Q2: SELECT a FROM R WHERE b> 10 GROUP BY a;(A)QI and Q2 produce the same answer.(B)The answer to QI is always contained in the answer to Q2.(C)The answer to Q2 is always contained in the answer to QI.(D)QI and Q2 produce different answers.Consider the following two SQL queries on relations R(a,b) and S(c):QI: SELECT a FROM RWHERE b > ALL (SELECT c FROM S);Q2: SELECT a FROM RWHERE b > ANY (SELECT c FROM S);(A)Q1 and Q2 always produce the same answer.(B)The answer to QI is always contained in the answer to Q2・(C)The answer to Q2 is always contained in the answer to QI.(D)None of the above.Given R(A,B)={('a;10),('b;20),('c',30)}, and execute the following three statements. What is the result of the last statement?create view V as select A from R where B>10;insert into V values('cT);select count(*) from V;(A)1 (B) 2 (C) 3 (D) 4Given a relation R(x) and two queries as follows:QI: SELECT x FROM R;Q2: (SELECT x FROM R) UNION (SELECT x FROM R);(A)QI and Q2 produce the same answer.(B)The answer to QI is always contained in the answer to Q2.(C)The answer to Q2 is always contained in the answer to QI.(D)None of the above.In the 3-valued logic used by SQL, suppose x has the value NULL and y is TRUE, the result for (x > 1) OR y is:(A)FALSE (B) UNKNOWN (C) TRUE (D) NULLConsider the following two SQL queries on relations R(a?b) and S(b9c):QI: (RNATURAL FULL OUTER JOIN S)UNION(R NATURAL JOIN S);Q2: (R NATURAL LEFT OUTER JOIN S)UNION(R NATURAL RIGHT OUTER JOIN S);(A)QI and Q2 produce the same answer.(B)The answer to QI is always contained in the answer to Q2.(C)The answer to Q2 is always contained in the answer to QI.(D)QI and Q2 produce different answers.Suppose that relation R(A,B) has 100 tuples and S(B,C) has 50 tuples. The number of tuples in R NATURAL LEFT OUTER JOIN S is at most:(A) 50 (B) 100 (C) 150 (D) 5000Assume that a relation R(a,b) has no NULL's but may have duplicates・ Compare the following two queries:QI: SELECT count(*) FROM R GROUP BY a;Q2: SELECT count(b) FROM R GROUP BY a;(A)QI and Q2 produce the same answer.(B)The answer to QI is always contained in the answer to Q2.(C)The answer to Q2 is always contained in the answer to QI.(D)QI and Q2 produce different answers.In the following, the results of QI and Q2 should be taken to be the result of the final SELECT * FROM R. Assume that the schema of relation R is R(a,b).QI: DELETE FROM R WHERE a=10;INSERT INTO R VALUES(10,5);SELECT * FROM R;Q2: UPDATE R SET b=5 WHERE a=10;SELECT * FROM R;(A)QI and Q2 produce the same answer.(B)The answer of QI is contained in the answer of Q2.(C)The answer of Q2 is contained in the answer of QI.(D)QI and Q2 produce different answers.IntegritySuppose we have the following table declarations: CREATE TABLE A (w INT PRIMARY KEY); CREATE TABLE B (x INT PRIMARY KEYREFERENCES A(w) ON DELETE SET NULL); CREATE TABLE C (y INT REFERENCES A(w)); CREATE TABLE D (zl INT REFERENCES B(x) ON DELETE SET NULL, z2 INT REFERENCES A(w) ON UPDATE CASCADE);Consider the following scripts: (1)DELETE FROM C; DELETE FROM B; DELETE FROM A; DELETE FROM D;(2)DELETE FROM C; DELETE FROM D; DELETE FROM A; DELETE FROM B;(3)DELETE FROM B; DELETE FROM C; DELETE FROM D; DELETE FROM A;Which of the above scripts will empty all four tables, without error?(A)⑶ only(B)(1) only(C)(2) and (3) only(D)(1) and (3) onlySuppose R is declared asCREATE TABLE R (a INT REFERENCES S(b)ON UPDATE CASCADE); Which of the following modifications on S will never be rejected for violating the referential integrity constraint?(I)DELETE FROM S;(II)UPDATE S SET b = 10;(III)INSERT INTO S(b)VLAUES(IO);(A)(I)(H)(B)(11)(111)(C)(i)(m)(D)None of (1),(11)9(111)Suppose we want to enforce the FD A T B on R(A,B,C) using triggers. Consider the following operations. For which of them dowe need to create a trigger on R?(A)delete on R(B)update of C on R(C)insert on R(D)All of the aboveSuppose we want to enforce the MVD: A TT B on R(A,B,C) using triggers・ Consider the following operations. For how many of them should we create a trigger?(1)INSERT ONR(2)DELETE ON R(3)UPDATE OF A ON R(4)UPDATE OF B ON R(5)UPDATE OF C ON R(A) 2 (B) 3 (C) 4 (D) 5Suppose you find the following statement in a program:... FETCH FROM myCursor INTO myVar ... Then the program may be written in:(A)Embedded SQL only(B)SQL/PSM only(C)Both Embedded SQL and SQL/PSM(D)None of the aboveTransactionAssume that we have a relation Employee(TD, salary) where ID is the key,and that Employee initially has two tuples (A,20) and (B,30). Consider the following two concurrent transactions: Tl: BEGIN TRANSACTION;UPDATE Employee SET salary = 2*salaryWHERE ID =,A,;UPDATE Employee SET salary = salary+10WHERE ID = W;COMMIT;T2: BEGIN TRANSACTION;SELECT AVG(salary) AS sail FROM Employee;SELECT AVG(salary) AS sal2 FROM Employee; COMMIT; Suppose that T1 and T2 execute at isolation level SERIALIZABLE and READ COMMITTED respectively, which of the following is an impossible pair of values for sail and sal2 returned by T2?(A)(35,40)(B)(40,40)(C)(25,25)(D)(25,40)PrivilegeSuppose user A is the owner of relation R(a,b). The following sequence of grants and revocation occurs:A: GRANT update on R to BA: GRANT update(a) on R to C WITH GRANT OPTION C: GRANT update(a) on R to B WITH GRANT OPTION A: REVOKE update(a) on R FROM C CASCADE Which of the following statement can user B do?(I)UPDATE R SET a=a+l;(II)GRANT update on R to C;(III)SELECT * FROM R;(A)only (I)(B)(1)(11)(C)(1)(11)(111)(D)None of (1)(11)(111)OO/OR Consider the following ODL declarations:class X (key A,B){ attribute integer A; attributeinteger B; relationship Y R1 inverse Y::R2; }; };class Y (key C) { attribute integer C; attribute integer D; relationship Set<X> R2 inverse X::R1;Which of the following relation schemas are produced according to the standard translation in the textbook?(A)X(A,B) and Y(A9C5D)(B)X(A,B,C) and Y(C,D)(C)X(A,B) and Y(C,D)(D)X(A,B),Y(C,D) and R(A,B,C)Datalog/RecursionThe following queries are recursive Datalog, and as for all Datalog queries, the result is a set, not a bag.QI: Path(x9y) <- Arc(x?y)Path(x,y) <- Path(x?a) AND Path(a?b) AND Path(b,y)Q2: Path(x,y) <- Arc(x,y)Path(x,y) <- Path(x,z) AND Path(z,y)(A)Q1 and Q2 produce the same answer.(B)The answer to QI is always contained in the answer to Q2.(C)The answer to Q2 is always contained in the answer to QI.(D)QI and Q2 produce different answers.Given a relation R(A) = {1,2,3}・ Consider the following query that involves a recursively defined relation P(X,Y):WITH RECURSIVE P(X,Y) AS(SELECT A AS X, A+l AS Y FROM R)UNION(SELECT COUNT(*) AS X,MAX(Y) AS Y FROM P)SELECT COUNT(*) FROM P;What value is in the result of this queiy?(A) 3 (B) 4 (C) 5 (D) None of the aboveXMLConsider the following XML DTD:<! DOCTYPE R [<!ELEMENT R(A+,B+)><!ELEMENT A(X,Y*)><! ELEMENT X(#PCDATA)><!ELEMENT Y(#PCDATA)><!ELEMENT B(#PCDATA|Z)><! ELEMENT Z(#PCDATA)>]>How many elements are there in the smallest XML document (i.e.?a document containing the fewest possible elements) that conforms to the above DTD? Note that text values are not elements.(A) 3 (B)4 (C)5 (D)6 Assume that the XML document in file "XYZ.xml,,conforms to the following DTD:<!DOCTYPE A[VELEMENT A(B*, C*)><!ELEMENT B (#PCDATA)><! ELEMENT C (#PCDATA)>]>Consider the following two queries in XQuery:QI: for $x in doc("XYZ.xml”)/A/Breturn $xQ2: let $x := doc(“XYZ.xml J $y := $x/A/Breturn $y(A)QI and Q2 produce the same answer.(B)The answer to QI is always contained in the answer to Q2.(C)The answer to Q2 is always contained in the answer to QI.(D)QI and Q2 produce different answers.。