今天考数据库,这是题目和我的答案!

数据|数据库

题目:

一.单项选择

 

1.

 

With respect to a relational table, what is a key?

 

 

 

 (a) A minimal subset of columns that uniquely identifies a row in the table (b) The ID and password needed to access the table (c) The subset of all the rows and columns in the table that are visible to all users in the database system (d) The one column that uniquely identifies a row in the table

 

 

 

2.

 

Which of the following is true about the number of primary keys and alternate keys with respect to a table?

 

 

 

 (a) There can be many primary keys, but only one alternate key. (b) There can be only one primary key, but many alternate keys. (c) There can be only one primary key and only one alternate key. (d) There can be many primary keys and many alternate keys.

 

 

 

3.

 

An insertion operation will _____ if the insertion violates the uniqueness property of a key.

 

 

 

 (a) succeed with warning (b) crash the system (c) fail (d) succeed without warning

 

 

 

4.

 

An insertion operation will _____ if the inserted primary key has a NULL value.

 

 

 

 (a) succeed with warning (b) succeed without warning (c) fail (d) crash the system

 

 

 

5.

 

For two tables to be union compatible, corresponding columns from each table should have which of the following?

 

 

 

 (a) different domains (b) different names (c) the same domain (d) the same name

 

 

 

6.

 

In the relational model, which of the following is true about the data type of a column?

 

 

 

 (a) It need not be atomic and it cannot be an abstract data type. (b) It must be atomic and it cannot be an abstract data type. (c) It need not be atomic and it can be an abstract data type. (d) It must be atomic and it can be an abstract data type.

 

 

 

7.

 

What is an alternate key?

 

 

 

 (a) Any key that is not a primary key (b) The key to use when the primary key does not work (c) A key that was added to the table after the table was designed (d) A key that will become the primary key when the primary key is deleted

 

 

 

8.

 

What does a projection operation do?

 

 

 

 (a) It extends the number of columns in a table. (b) It selects rows from a table. (c) It extends the number of rows in a table. (d) It selects columns from a table.

 

 

 

9.

 

The result of a set difference operation r - s will be

 

 

 

 (a) tuples in r after deducting their values by the corresponding values in the tuples in s (b) tuples in s after deducting their values by the corresponding values in the tuples in r (c) those tuples that are in s but not in r (d) those tuples that are in r but not in s

 

 

 

10.

 

Which of the following is true about primary keys and foreign keys holding NULL value?

 

 

 

 (a) A primary key can hold a NULL value and a foreign key cannot hold a NULL value (b) A primary key cannot hold a NULL value and a foreign key cannot hold a NULL value (c) A primary key can hold a NULL value and a foreign key can hold a NULL value (d) A primary key cannot hold a NULL value and a foreign key can hold a NULL value

 

 

 

11.

 

In contrast to _____ tables, a view refers to _____.

 

 

 

 (a) base, a virtual table (b) empty, non-empty tables (c) non-empty, empty tables (d) virtual, base tables

 

 

 

12.

 

When removing a table from the schema, using the CASCADE option would

 

 

 

 (a) remove the table and all references to it (b) recursively remove the table and all other tables that the removed table refers to (c) remove the table and all other tables that the specified table refers to. (d) remove the table if there are no references to it

 

 

 

13.

 

In a transaction, COMMIT specifies that

 

 

 

 (a) all updates (including inserts, deletes, modifications) of a transaction are about to be made permanent in the database (b) all updates (including inserts, deletes, modifications) of a transaction are to be made permanent in the database (c) only the inserts and deletes of a transaction are to be made permanent in the database (d) only the inserts and deletes of a transaction are about to be made permanent in the database

 

 

 

14.

 

Which of the following is true about the physical storage of tables defined by views?

 

 

 

 (a) Extra physical storage is needed for storing the tables defined by views, only if views define additional non-existing columns. (b) There is no extra physical storage needed to store tables that a view defines. (c) Extra physical storage is always needed to store tables that a view defines. (d) Extra physical storage is needed to store tables that a view defines, only when rows are inserted into the view.

 

 

 

15.

 

Which of the following SQL commands can be used to change, add, or drop column definitions from a table?

 

 

 

 (a) MODIFY TABLE (b) UPDATE TABLE (c) CHANGE TABLE (d) ALTER TABLE

 

 

 

16.

 

Which of the following SQL commands can be used to destroy and remove a table from the schema?

 

 

 

 (a) DROP TABLE (b) DESTROY TABLE (c) REMOVE TABLE (d) DELETE TABLE

 

 

 

17.

 

In SQL, which of the following operators are used to check for set membership in a SELECT statement?

 

 

 

 (a) MEMBER and NOT MEMBER (b) IN and NOT IN (c) SUBSET and NOT SUBSET (d) COMPONENT and NOT COMPONENT

 

 

 

18.

 

In SQL, the results of a _____ statement can be used to process a _____ statement.

 

 

 

 (a) INSERT, SELECT (b) SELECT, INSERT (c) INSERT, DELETE (d) DELETE, INSERT

 

 

 

19.

 

In a transaction, a ROLLBACK is used to

 

 

 

 (a) roll all the updates (including inserts, deletes, modifications) of an aborted transaction into the database (b) roll only the inserts and deletes of an aborted transaction into the database (c) discard all the updates (including inserts, deletes, modifications) of a transaction from the database (d) discard only the inserts and updates of a transaction from the database

 

 

 

20.

 

When a string whose length is strictly less than n is entered as the value of a field whose SQL data type is CHAR(n), the system responds by

 

 

 

 (a) padding the end of the string with spaces to length n before storing it (b) padding the end of the string with NULL characters to length n before storing it (c) re-prompting for the entry of a string whose length is exactly n (d) storing the string as is

 

 

Copyright 2004 iCarnegie, Inc. All rights reserved.

 二.问答类

Database Systems Practical
Answer the following questions:

1.      Let the following relational tables be given: R = (A, B, C) and S = (D, E, F) where A, B, C, D, E, and F are the attributes (columns). Write the SQL statements that will express each of the queries given below:

1.      ΠA(R)

2.      σB = 13(R)

3.      ΠA,B(R

C = D S)

2.      Given relation r as:

ename

project

dept

Kasper

Forecast

Accounting

Kasper

Audit

Accounting

Kasper

Spreadsheet

Admin

Mohan

Forecast

Accounting

Mohan

Audit

Admin

Mohan

Spreadsheet

Admin

Lin

Forecast

Admin

Lin

Audit

Admin

Lin

Spreadsheet

Admin

3.      Given relation s as:

ename

dept

Kasper

Accounting

Mohan

Admin

Lin

Admin

4.      Provide the results of the following operations. If an operation cannot be performed, state the reasons. Do not write the equivalent SQL statements.

1.      σdept = 'Admin' AND project <> 'Audit'(r)

2.      r U s

3.      Πdept(r) - Πdept(s)

5.      Consider the following Mail Order database:

CUSTOMER

CId

Name

Address

Zip

11

George

23 Main St.

15218

22

Barbara

3 Walnut St.

15217

33

Waquim

82 Straton Av.

15280

6.
 

PART

Pno

Pname

UnitPrice

150

X

20.00

152

Y

33.00

153

Z

4.00

155

V

15.00

162

W

25.00

7.
 

ORDERS

Ono

CId

Received

Shipped

20

11

10-Dec-97

12-Dec-97

21

11

13-Feb-98

15-Feb-98

22

22

26-Feb-98

NULL

8.
 

INVOICE

Ono

Pno

Qty

BilledPrice

20

152

1

33.00

20

155

4

60.00

20

162

1

25.00

22

152

3

99.00

21

150

1

20.00

21

152

2

66.00

21

153

3

12.00

21

155

4

60.00

21

162

1

25.00

9.      In the table ORDERS above, specify in SQL the requirements that:

1.      Received date cannot be undefined and that

2.      the Shipped date, if it is not NULL, should be greater than the Received date.

10.  Translate in SQL the following queries. Note: The "Received" column in ORDERS table above refers to when the order is received by the system (and not when the ordered items are received by the customer).

1.      Get the part number of parts that cost between 10 and 25 dollars.

2.      For each part sold in 1998, list the total quantity sold in 1998. Sort your results in ascending order by the total billed price for each part for that year. Parts are considered sold when an order is received. The BilledPrice column in the Invoice table indicates the total price billed for that part (i.e., quantity sold multiplied by unit price minus discount, if any).

3.      Get those parts that were not sold in 1998. A part is considered sold when an order is received.

11.  Given the following schema definitions, specify in SQL2 the referential integrity constraint on the EMPLOYEE relation that will prevent an employee from being assigned to a non-existent department.

12.  create table EMPLOYEE

13.    (id      id_dom primary key deferrable,

14.     name    name_dom,

15.     salary  salary_dom,

16.     dname   dept_name_dom

17.     );

18. 
 

19.  create table DEPARTMENT

20.     (name   dept_name_dom primary key deferrable,

21.      mgrid  id_dom        foreign key references emp(id) deferrable,

22.      budget budget_dom

23.            );

 

 

 

Copyright 2004 iCarnegie, Inc. All rights reserved.

我交的答案,很可能有错,等老帅评讲后,我再给出标准答案:

/*********************PARTI*********************/

Answer for Multiple-choice:

1 ~ 5:ABACC

6 ~10:DDADC

11~15:AABCD

16~20:ABBCD

/*********************PARTII*********************/

Answer for Practical:

1.

1)SELECT A

  FROM R

2)SELECT B

  FROM R

  WHERE B=’13’

3)USE Pubs

SELECT A,B FROM R INNER JOIN S

ON R.C=S.D

4.

1) ename     project        dept

  Kasper      Spreadsheet    Admin

Mohan       Spreadsheet    Admin

Lin          Forecast     Admin

Lin          Spreadsheet    Admin

2) ename     project        dept

Kasper     Forecast      Accounting

Kasper     Audit          Accounting

Kasper     Spreadsheet    Admin

Mohan      Forecast      Accounting

Mohan     Audit          Admin

Mohan     Spreadsheet    Admin

Lin          Forecast      Admin

Lin          Audit          Admin

Lin          Spreadsheet    Admin

3)这里将不会返回任何值,因为语句的意思是取出列dept中属于r但不属于s的所有值,显然不存在这样的值。

9.

1)ALTER TABLE ORDERS

ALTER COLUMN Received

   datetime NOT NULL

2)ALTER TABLE ORDERS

  CONSTRAINT Shipped1 UNIQUE(Shipped)

  CONSTRAINT Shipped2 CHECK(Shipped = “” OR Shipped > Received)

10.

1)      SELECT Pno

FROM PART

WHERE UnitPrice > 10 AND UnitPrice <25

2) SELECT Ono,Qty,BilledPrice

FROM INVOICE

WHERE Ono IN (SELECT Ono

                 FROM ORDERS

                 WHERE Received LIKE "%1998")

COMPUTE SUM(Qty)

ORDER BY BilledPrice ASC

3) SELECT Ono,Pno,Qty,BilledPrice

     FROM INVOICE

     WHERE Ono NOT IN (SELECT Ono

                         FROM ORDERS

                         WHERE Received LIKE "%1998"))

11.

CREATE TABLE EMPLOYEE(

id_dom  NUMERIC(20) NOT NULL,

name_dom  VARCHAR(40) NOT NULL,

salary_dom  VARCHAR(40) NOT NULL,

dept_name_dom VARCHAR(40) NOT NULL,

PRIMARY KEY (id_dom));

 

CREATE TABLE DEPARTMENT(

dept_name_dom VARCHAR(40) NOT NULL,

id_dom  NUMERIC(20) NOT NULL,

budget_dom VARCHAR(40) NOT NULL,

PRIMARY KEY (dept_name_dom),

FOREIGN KEY (id_dom) REFERENCES EMPLOYEE (id_dom));

时间: 2024-11-01 10:06:08

今天考数据库,这是题目和我的答案!的相关文章

2011-10-15腾讯校园招聘笔试题目与参考答案

这里的题目收集于网上,真实信应该是真的   1,下列排序算法中,初始数据集的排序程序对算法性能无影响的是() A,插入排序B,堆排序 C,冒泡排序,D,快速排序  答案:B,冒泡的复杂度恒定为O(n^2),插入排序最差是O(n^2),最优化为O(n);堆排序建堆的时间是O(n),但是,排序的过程是O(nlogn),固定不变; 冒泡排序虽然大家都认为是O(n^2),但是,优化的冒泡是使用一个flag的,如果flag不变,说明不需要 再交换元素了,最优可以到O(n),快速排序不解释,最差的情况每一次

《OOXX》全部题目及图文答案

<OOXX>图文答案(1)是是非非,真真假假,虚虚实实--你能猜中几回?<OOXX>是一款有趣的问答游戏,游戏只有O和X两个选项,分不同级数挑战,每升高一集答题时间越短,跳过的机会越少,正确回答的题目数也越多,来看看你各个知识面吧~目前小编也是在不断挑战.更新中--会陆续把全部题目的答案更新上来,各位可以收藏本篇保存~动画片<死神>中,黑崎一护的卐解的名字叫做天锁斩月----------O<七龙珠>中,孙悟天和特兰克斯融合后的名字叫齐天大圣--------X

求以下java笔试题目的最佳答案!!!

问题描述 1.RCPPurposeoftheprojectTestthecandidate'slearningcapabilityandproblemsolvingskillRequirements1.DesignaneclipseRCPapplicationwhichusesmenuorbuttontodisplay"hello,world".2.Designamodulewhichwilladdmenuorbuttontothepreviousapplication,thenewm

2013-C++第9周OJ题目及参考答案

课程首页在:http://blog.csdn.net/sxhelijian/article/details/11890759 Problem A: A+B 问题[平台使用练习] Description 计算 a+b Input 两个整型数 a,b Output Output a+b Sample Input 1 2 Sample Output 3  参考解答 #include <iostream> using namespace std; int main() { int a,b; cin &

2013-C++第10周OJ题目及参考答案

课程首页在:http://blog.csdn.net/sxhelijian/article/details/11890759 1030 Problem  A 求奖金总数 Description 企业发放的奖金根据利润提成.利润低于或等于100000元的,奖金可提10%; 利润高于100000元,低于200000元(100000<I≤200000)时,低于100000元的部分按10%提成,高于100000元的部分,可提成 7.5%; 200000<I≤400000时,低于200000元部分仍按上

数据库能力测试I(题目源自于CSDN论坛)

数据|数据库 [DB基础](10) 选答题, 从下列题目中任选题分值满10分的作答. SYBASE A.(5)软件公司的张工在备份数据库除了备份应用数据库本身以外, 还备份master数据库,为什么?   B.(5)SYBASE的VIEW创建有那些限制?   ORACLE A.(5)解释归档和非归档模式之间的不同和它们各自的优缺点   B.(5) 兩個結果集互加及互減的函數   综合 A.(10)取一表前N筆記錄的各种數据庫的寫法... 至少写出三种写法.   [SQL常识](30) A. (5

C#写个文本文件导入数据库的程序

问题描述 文本文件(text.txt)里有有若干道试题,格式是这样这是其中一道,题目和选项一列,答案一列."为切实加强公安信息网络安全管理工作,规范公安机关人民警察使用公安信息网,落实()的管理责任制,根据<中华人民共和国人民警察法>.<中华人民共和国计算机信息系统安全保护条例>等有关法律.法规,制定本规定.A谁主管.谁负责B谁使用.谁负责C谁负责.谁使用D谁负责.谁主管","AB"导入数据库pubs下的test表中,题目和试题对应表中的ST

请人做个小软件,类似答题器。大概要多少钱。太贵我付不起,应付考试用的。诚心来

问题描述 大概要多少钱.太贵我付不起,应付考试用的.诚心来 解决方案 解决方案二:太少我不做解决方案三:该回复于2012-03-19 13:43:36被版主删除解决方案四:先描述一下功能.详细一点.总得让别人了解你的需求吧.解决方案五:其实这些网上斗都有的try解决方案六:题型是选择题,有N科,我需要两种功能,1.学习功能单科随即学习,单科顺序学习可以保存学习进度,2.考试功能对已经学习过的题目进行考试,要求出题随机但不能一题多出,就是说同样一道题反复出现,确保题库每道题都能抽到3.题型批量录入

请问怎样在数据库中储存选择题极其答案呢 ?

问题描述 要求用C# 和 sql sever 制作一个类似驾考的应用程序 没有什么概念....就是很多选择题...一题一题点下去..有多选有单选...还有判断最后计算出一共得了多少分···数据库应该怎么建表呢...题目一张 答案一张还是具体怎么弄...把所有的题目和答案都存在一张表格里然后再调用..? 可是那些答案有好几个选项啊...A B C D 四个存在不同的列里吗? 有些是单选 有些是多选....(勉强会用C#制作基本界面 能使用一些基本数据库语句的菜鸟 从来没做过项目..好迷茫) 解决方