数据库第3章习题解答

合集下载

第3章习题及部分解答

第3章习题及部分解答

3.5设有一个SPJ数据库,包括S,P,J,SPJ四个关系模式:S(SNO,SNAME,STATUS,CITY); P(PNO,PNAME,COLOR,WEIGHT); J(JNO,JNAME,CITY);SPJ(SNO,PNO,JNO,QTY);1、供应商表S由供应商代码(SNO)、供应商姓名(SNAME)、供应商状态(STATUS)、供应商所在城市(CITY)组成;2、零件表P由零件代码(PNO)、零件名(PNAME)、颜色(COLOR)、重量(WEIGHT)组成;3、工程项目表J由工程项目代码(JNO)、工程项目名(JNAME)、工程项目所在城市(CITY)组成;4、供应情况表SPJ由供应商代码(SNO)、零件代码(PNO)、工程项目代码(JNO)、供应数量(QTY)组成,表示某供应商供应某种零件给某工程项目的数量为QTY。

试用关系代数语言完成如下查询:1)找出所有供应商的姓名和所在城市;2)找出所有零件的名称、颜色、重量;3)找出使用供应商S1所供应零件的工程号码;4)找出工程项目J2使用的各种零件的名称及其数量;5)找出上海厂商供应的所有零件号码;6)找出使用上海产的零件的工程号码;7)找出没有使用天津产的零件的工程号码;8)把全部红色零件的颜色改成蓝色;9)由S5供给J4的零件P6改为由S3供应,请作必要的修改;10)从供应商关系中删除S2的记录,并从供应情况关系中删除相应的记录;11)求供应工程J1零件的供应商号码SNO;12)求供应工程J1零件P1的供应商号码SNO;13)求供应工程J1零件为红色的供应商号SNO;14)求没有使用天津供应商生产的红色零件的工程号JNO;15)求S1提供的零件名PNAME;16)求给工程J1和J2提供零件的供应商号码SNO;解:1)找出所有供应商的姓名和所在城市;Select SNAME,CITY From S2)找出所有零件的名称、颜色、重量;Select PNAME,COLOR,WEIGHT From P3)找出使用供应商S1所供应零件的工程号码;Select JNO From SPJ Where SNO= ‘S1’4)找出工程项目J2使用的各种零件的名称及其数量;Select PNAME,QTY From SPJ,PWhere SPJ.PNO=P.PNO And JNO=‘J2’5)找出上海厂商供应的所有零件号码;Select PNO From S,SPJWhere SPJ.SNO=S.SNO And CITY=‘上海’6)找出使用上海产的零件的工程号码;Select JNAME From J,SPJ,S Where J.JNO=SPJ.JNOAnd S.SNO=SPJ.SNO And S.CITY=‘上海’7)找出没有使用天津产的零件的工程号码;Select JNO From SPJ Where SNONOT IN(Select SNO From S Where CITY= ‘天津’)8)把全部红色零件的颜色改成蓝色;Updat P SET COLOR=‘蓝’ Where COLOR=‘红’9)由S5供给J4的零件P6改为由S3供应,请作必要的修改;Updat SPJ SET SNO=‘S3’Where SNO=‘S5’ And JNO=‘J4’ And PNO=‘P6’10)从供应商关系中删除S2的记录,并从供应情况关系中删除相应的记录;Delete From S Where SNO=‘S2’Delete From SPJ Where SNO=‘S2’11)求供应工程J1零件的供应商号码SNO;Select SNO From SPJ Where JNO=‘J1’12)求供应工程J1零件P1的供应商号码SNO;Select SNO From SPJ Where JNO=‘J1’ And PNO=‘P1’13)求供应工程J1零件为红色的供应商号SNO;Select SNO From P,SPJWhere P.PNO=SPJ.PNO And JNO=‘J1’ And COLOR=‘红’14)求没有使用天津供应商生产的红色零件的工程号JNO; Select JNO From SPJ Where JNO NOT IN(Select JNO From S,SPJ,P Where S.SNO=SPJ.SNOAnd P.PNO=SPJ.PNO And COLOR=‘红’ And CITY=‘天津’)15)求S1提供的零件名PNAME;Select PNAME From SPJ,PWhere P.PNO=SPJ.PNO And SNO=‘S1’16)求同时给工程J1和J2提供零件的供应商号码SNO;Select SNO From SPJ Where JNO=‘J1’And SNO IN(Select SNO From SPJ Where JNO=‘J2’)或Select SNO From SPJ Where JNO=‘J1’INTERSECT Select SNO From SPJ Where JNO=‘J1’3.6 什么是基本表?什么是视图?两者的区别和联系是什么?3.11 请为三建工程建立一个供应情况的视图,包括供应商代码SNO、零件代码PNO、供应数量QTY。

数据库第三章所有例题参考答案

数据库第三章所有例题参考答案

11级信管,保密,图档上机考试题目与参考答案3.3Simple Select Statements1.EXAMPLE 3.3.1find the aid values and names of agents that are based in New York. select aid, aname from agents where city=’New York’;2.EXAMPLE3.3.3Retrieve all pid values of parts for which orders are placed.select distinct pid from orders;3.EXAMPLE 3.3.4retrieve all customer-agent name pairs, (cname, aname), where the customer places an order through the agent.select distinct ame,agents.anamefrom customers,orders,agentswhere customers.cid=orders.cid and orders.aid=agents.aid;4.EXAMPLE 3.3.6all pairs of customers based in the same city.select c1.cid, c2.cidfrom customers c1, customers c2where c1.city = c2.city and c1.cid < c2.cid;5.EXAMPLE 3.3.7find pid values of products that have been ordered by at least twocustomers.select distinct x1.pidfrom orders x1, orders x2where x1.pid = x2.pid and x1.cid < x2.cid;6.EXAMPLE 3.3.8Get cid values of customers who order a product for which an order is also placed by agent a06.select distinct y.cidfrom orders x, orders ywhere y.pid = x,pid and x.aid = ‘a06’;3.4Subqueries7.EXAMPLE 3.4.1Get cid values of customers who place orders with agents in Duluth or Dallas.select distinct cid from orderswhere aid in (select aid from agentswhere city= ‘Duluth’ or city = ‘Dallas’)8.EXAMPLE 3.4.2to retrieve all information concerning agents based in Duluth or Dallas (very close to the Subquery in the previous example).select * from agentswhere city in (‘Duluth’, ‘Dallas’ );or select *from agentswhere city = ‘Duluth’ or city = ‘Dallas’;9.EXAMPLE 3.4.3to determine the names and discounts of all customers who place orders through agents in Duluth or Dallas.select distinct cname, discnt from customerswhere cid in (select cid from orders where aid in(select aid from agents where city in (‘Duluth’, ‘Dallas’ ))); 10.EXAMPLE 3.4.4to find the names of customers who order product p05.select distinct cname from customers, orderswhere customers.cid = orders.cid and orders.pid = ‘p05’or select disti nct cname from customers where ‘p05’ in(select pid from orders where cid = customers.cid);11.EXAMPLE 3.4.5Get the names of customers who order product p07 from agent a03. select distinct cname from customerswhere cid in (select cid from orders where pid = ‘p07’ and aid = ‘a03’) 12.EXAMPLE 3.4.6to retrieve ordno values for all orders placed by customers in Duluth through agents in New York.select ordno from orders x where exists(select * from customers c, agents awhere c.cid = x.cid and a.aid = x.aid and c.city = ‘Duluth’ anda.city=‘New York’);13.EXAMPLE 3.4.7find aid values of agents with a minimum percent commission.select aid from agents where percent = (select min(percent) from agents);14.EXAMPLE 3.4.8find all customers who have the same discount as that of any of the customers in Dallas or Boston.select cid, cname from customerswhere discnt = some (select discnt from customerswhere city = ‘Dallas’ or city = ‘Boston’);15.EXAMPLE 3.4.9Get cid values of customers with discnt smaller than those of any customers who live in Duluth.select cid from customerswhere discnt <all (select discnt from customerswhere city = ‘Duluth’);16.EXAMPLE 3.4.10Retrieve all customer names where the customer places an order through agent a05.select distinct ame from customers cwhere exists (select * from orders xwhere c.cid = x.cid and x.aid = ‘a05’);or select distinct ame from customers c, orders xwhere c.cid = x.cid and x.ai d = ‘a05’ ;17.EXAMPLE 3.4.11Get cid values of customers who order both products p01 and p07. select distinct cid from orders xwhere pid = ‘p01’ and exsits (select * from orderswhere cid = x.cid and pid = ‘p07’);orselect distinct x.cid from orders x, orders ywhere x.pid = ‘p01’ and x.cid = y.cid and y.pid = ‘p07’;18.EXAMPLE 3.4.12Retrieve all customer names where the customer does not place an order through agent a05.select distinct ame from customers cwhere not exists (select * from orders xwhere c.cid = x.cid and x.aid = ‘a05’);19.EXAMPLE 3.4.13retrieving all customer names where the customer does not place an order through agent a05, but using the two equivalent NOT IN and <>ALLpredicates in place of NOT EXISTS.select distinct ame from customers cwhere c.cid not in (select cid from orders where aid = ‘a05’);or select ame from customers cwhere c.cid <>all (select cid from orders where aid = ‘a05’);20.EXAMPLE 3.4.14Find cid values of customers who do not place any order through agent a03.select distinct cid from orders xwhere not exists (select * from orderswhere cid = x.cid and aid = ‘a03’);orselect cid from customers cwhere not exists (select * from orderswhere cid = c.cid and aid = ‘a03’);21.EXAMPLE 3.4.15Retrieve the city names containing customers who order product p01. select distinct city from customers where cid in(select cid from orders where pid = ‘p01’);or select distinct city from customers where cid =some(select cid from orders where pid = ‘p01’);or select distinct city from customers c where exsits(select * from orders where cid = c.cid and pid = ‘p01’);or select distinct city from customers c, orders xwhere x.cid = c.cid and x.pid = ‘p01’;or select distinct city from customers c where ‘p01’ in(select pid from orders where cid = c.cid);3.5UNION Operators and FOR ALL Conditions 22.EXAMPLE 3.5.1to create a list of cities where either a customer or an agent, or both, is based.select city from customersunion select city from agents;23.EXAMPLE 3.5.2Get the cid values of customers who place orders with all agents based in New York.select c.cid from customers cwhere not exsits(select * from agents awhere a.city = ‘New York’ and not exsits(select * from orders xwhere x.cid = c.cid and x.aid = a.aid));24.EXAMPLE 3.5.3Get the aid values of agents in New York or Duluth who place orders forall products costing more than a dollar.select aid from agents awhere (a.city = ‘New York’ or a.city = ‘Duluth’)and not exsits(select p.pid from products pwhere p.price > 1.00 and not exsits(select * from orders xwhere x.pid = p.pid and x.aid = a.aid));25.EXAMPLE 3.5.4Find aid values of agents who place orders for product p01 as well as for all products costing more than a dollar.select a.aid from agents a where a.aid in(select aid from orders where pid = ‘p01’)and not exsits (select p.pid from products pwhere p.price > 1.00 and not exsits (select * from orders xwhere x.pid = p.pid and x.aid = a.aid));or select distinct y.aid from orders ywhere y.pid = ‘p01’ and not exsits(select p.pid from products pwhere p.price > 1.00 and not exsits(select * from orders xwhere x.pid = p.pid and x.aid = y.aid));26.EXAMPLE 3.5.6Find pid values of products supplied to all customers in Duluth.select pid from products pwhere not exsits(select c.cid from customers cwhere c.city = ‘Duluth’and not exists(select * from orders xwhere x.pid = p.pid and x.cid = c.cid));3.7 Set Functions in SQL27.EXAMPLE 3.7.1determine the total dollar amount of all orders.select sum(dollars) as totaldollars from orders28.EXAMPLE 3.7.2To determine the total quantity of product p03 that has been ordered. select sum(qty) as TOTAL from orders where pid=’p03’29.EXAMPLE 3.7.4Get the number of cities where customers are based.select count(distinct city) from customers30.EXAMPLE 3.7.5List the cid values of alt customers who have a discount less than the maximum discount.select cid from customerswhere discnt < (select max(discnt) from customers)31.EXAMPLE 3.7.6Find products ordered by at least two customers.select p.pid from products pwhere 2 <=(select count(distinct cid) from orders where pid=p.pid)图档的学生的上机考查的考题到此为止___________________________________________________________ ___________________________________________________________ 信管,保密的学生上机考查还包括下面的题目32.EXAMPLE 3.7.7Add a row with specified values for columns cid, cname, and city (c007, Windix, Dallas, null)to the customers table.insert into customers(cid, cname, city)values (‘c007’, ‘Windix’, ‘Dallas’)33.EXAMPLE 3.7.9After inserting the row (c007, Windix, Dallas, null) to the customers table in Example 3.7.7, assume that we wish to find the average discount of all customers.select avg(discnt) from customers3.8 Groups of Rows in SQL34.EXAMPLE 3.8.1to calculate the total product quantity ordered of each individual product by each individual agent.select pid, aid, sum(qty) as TOTAL from ordersgroup by pid, aid35.EXAMPLE 3.8.2Print out the agent name and agent identification number, and the product name and product identification number, together with the total quantity each agent supplies of that product to customers c002 and c003.select aname, a.aid, pname, p.pid, sum(qty)from orders x, products p, agents awhere x.pid = p.pid and x.aid = a.aid and x.cid in (‘c002’, ‘c003’)group by a.aid, a.aname, p.pid, p.pname36.EXAMPLE 3.8.3Print out all product and agent IDs and the total quantity ordered of the product by the agent, when this quantity exceeds 1000.select pid, aid, sum(qty) as TOTAL from ordersgroup by pid, aidhaving sum(qty) > 100037.EXAMPLE 3.8.4Provide pid values of all products purchased by at least two customers. select distinct pid from ordersgroup by pidhaving count(distinct cid) >= 23.9 A Complete Description of SQL Select38.EXAMPLE 3.9.1List all customers, agents, and the dollar sales for pairs of customers and agents, and order the result from largest to smallest sales totals. Retain only those pairs for which the dollar amount is at least equal to 900.00. select ame, c.cid, a.aname, a.aid, sum(dollars) as casalesfrom customers c, orders o, agents awhere c.cid = o.cid, and a.aid = o.aidgroup by ame, c.cid, a.aname, a.aidhaving sum(o.dollars) >= 900.00order by casales desc39.EXAMPLE 3.9.2listed the cid values of all customers with a discount less than the maximum discount.select cid from customerswhere discnt < (select max(discnt) from customers)40.EXAMPLE 3.9.3Retrieve the maximum discount of all customers.select max(discnt) from customers;select distinct discnt from customers cwhere discnt >= all (select discnt from customers dwhere d.cid<>c.cid)41.EXAMPLE 3.9.4Retrieve all data about customers whose cname begins with the letter “A”.select * from customers where cname like ‘A%’42.EXAMPLE 3.9.5Retrieve cid values of customers whose cname does not have a third letter equal to “%”.select cid from customers where cname not like ‘__[%]’43.EXAMPLE 3.9.6Retrieve cid values of customers whose cname begins “Tip_” and has an arbitrary number of characters following.select cid from customers where cname like ‘TIP\[_]%’44.EXAMPLE 3.9.7Retrieve cid values of customers whose cname starts with the sequence “ab\”.select cid from customers where cname like ‘ab\%’3.10 Insert, Update, and Delete Statements 45.EXAMPLE 3.10.1Add a row with specified values to the orders table, setting the qty and dollars columns null.insert into orders (ordno, month, cid, aid, pid)values (1107, ‘aug’, ‘c006’, ‘a04’, ‘p01’)46.EXAMPLE 3.10.2Create a new table called swcusts of Southwestern customers, and insert into it all customers from Dallas and Austin.create table swcusts (cid char(4) not null,cname varchar(13),city varchar(20),discnt real);insert into swcustsselect * from customerswhere city in (‘Dallas’, ‘Austin’)47.EXAMPLE 3.10.3Give all agents in New York a 10% raise in the percent commission they earn on an order.update agents set percent = 1.1 * percent where city = ‘New York’48.EXAMPLE 3.10.4Give all customers who have total orders of more than $1000 a 10% increase in the discnt.update agents set percent = 1.1 * discntwhere cid in(select cid from orders group by cid having sum(dollars) > 1000) 49.EXAMPLE 3.10.6Delete all agents in New York.delete from agents where city = ‘New York’50.EXAMPLE 3.10.7Delete all agents who have total orders of less than $600.Delete from agents where aid in(select aid from ordersGroup by aidHaving sum(dollars)<600)51.EXAMPLE 3.11.2Retrieve the names of customers who order products costing $0.50. delete from agents where aid in(select aid from orders group by aid having sum(dollars)<600)(完)。

数据库习题答案

数据库习题答案

《数据库习题答案》来自五星文库点这里,有很多篇《数据库习题答案》在线阅读本文:数据库习题答案导读:第三章习题,1.关系数据库设计理论,数据依赖范式和关系模式的规范化设计方法,其中数据依赖起着核心的作用,2.关系数据库中的关系模式至少要满足第一范式,如果每个属性值都是不可再分的最小数据单位,(2)试分析模式R的数据冗余问题,关系R中的C属性会存在在数据冗余,相应地原来存储在一张二维表内的数据就要分散存储到多张二维表中,第四章习题,A删除基本表B修改基本表中的数据,A数据项B 元组,C表D数据库第三章习题一、单项选择题1.在关系模型R中,函数依赖X→Y的语义是( B )A.在R的某一关系中,若两个元组的X值相等,则Y值也相等B.在R的每一关系中,若两个元组的X值相等,则Y值也相等C.在R的某一关系中,X值应与Y值相等D.在R的每一关系中,X值应与Y值相等2.设学生关系模式为:学生(学号,姓名,年龄,性别,成绩,专业),则该关系模式的主键是( B )A.性别 B.学号C.学号,姓名 D.学号,姓名,性别3.如果X→Y(Y不包含于X,且Y不能决定X)和Y→Z成立,那么X→Z成立。

这条规则称为( B )A.自反律 B.传递律C.伪传递律 D.增广律4.关系模式R?2NF,则R一定是(b )A.1NF B.3NF5.设一关系模式为:运货路径(顾客姓名,顾客地址,商品名,供应商姓名,供应商地址),则该关系模式的主键是( C )A.顾客姓名,供应商姓名,供应商地址 B.顾客姓名,商品名C.顾客姓名,供应商姓名,商品名 D.顾客姓名,顾客地址6.下列有关范式的叙述中正确的是( B )A.如果关系模式R?1NF,且R中主属性完全函数依赖于主键,则R是2NFB.如果关系模式 R?3NF,则R?2NF一定成立C.如果关系模式R?1NF,则只要消除了R中非主属性对主键的传递依赖,则R可转换成2NFD.如果关系模式R?1NF,则只要消除了R中非主属性对主键的部分依赖,则R可转换成3NF7.关系模式学生(学号,课程号,名次),若每一名学生每门课程有一定的名次,每门课程每一名次只有一名学生,则以下叙述中错误的是( B )A.(学号,课程号)和(课程号,名次)都可以作为候选键B.只有(学号,课程号)能作为候选键C.该关系模式属于第三范式D.该关系模式属于BCNF8.已知关系模式R(ABCD),F={A→C,B→C,C→D },则以下成立的是( B )A.A→B B.A→DC.AD→BC D.AC→BD9.如果X→Y且Z?U成立,那么XZ→YZ成立,这条规则称为( D )A.自反律 B.传递律`C.伪传递律 D.增广律10.能够消除多值依赖引起的冗余是( D )A.1NF B.2NF二、填空题1.关系数据库设计理论,数据依赖范式和关系模式的规范化设计方法。

数据库习题答案-3

数据库习题答案-3

《数据库习题答案》来自五星文库点这里,有很多篇《数据库习题答案》在线阅读本文:数据库习题答案导读:第三章习题,1.关系数据库设计理论,数据依赖范式和关系模式的规范化设计方法,其中数据依赖起着核心的作用,2.关系数据库中的关系模式至少要满足第一范式,如果每个属性值都是不可再分的最小数据单位,(2)试分析模式R的数据冗余问题,关系R中的C属性会存在在数据冗余,相应地原来存储在一张二维表内的数据就要分散存储到多张二维表中,第四章习题,A删除基本表B修改基本表中的数据,A数据项B 元组,C表D数据库第三章习题一、单项选择题1.在关系模型R中,函数依赖X→Y的语义是(B )A.在R的某一关系中,若两个元组的X值相等,则Y值也相等B.在R的每一关系中,若两个元组的X值相等,则Y值也相等C.在R的某一关系中,X值应与Y值相等D.在R的每一关系中,X值应与Y值相等2.设学生关系模式为:学生(学号,姓名,年龄,性别,成绩,专业),则该关系模式的主键是( B )A.性别B.学号C.学号,姓名D.学号,姓名,性别3.如果X→Y(Y不包含于X,且Y不能决定X)和Y→Z成立,那么X→Z成立。

这条规则称为( B )A.自反律B.传递律C.伪传递律D.增广律4.关系模式R2NF,则R一定是(b )A.1NF B.3NFC.BCNF D.4NF5.设一关系模式为:运货路径(顾客姓名,顾客地址,商品名,供应商姓名,供应商地址),则该关系模式的主键是( C )A.顾客姓名,供应商姓名,供应商地址B.顾客姓名,商品名C.顾客姓名,供应商姓名,商品名D.顾客姓名,顾客地址6.下列有关范式的叙述中正确的是(B )A.如果关系模式R1NF,且R中主属性完全函数依赖于主键,则R是2NFB.如果关系模式R3NF,则R2NF一定成立C.如果关系模式R1NF,则只要消除了R中非主属性对主键的传递依赖,则R可转换成2NFD.如果关系模式R1NF,则只要消除了R中非主属性对主键的部分依赖,则R可转换成3NF7.关系模式学生(学号,课程号,名次),若每一名学生每门课程有一定的名次,每门课程每一名次只有一名学生,则以下叙述中错误的是( B )A.(学号,课程号)和(课程号,名次)都可以作为候选键B.只有(学号,课程号)能作为候选键C.该关系模式属于第三范式D.该关系模式属于BCNF8.已知关系模式R(ABCD),F={A→C,B→C,C→D },则以下成立的是( B )A.A→B B.A→DC.AD→BC D.AC→BD9.如果X→Y且ZU成立,那么XZ→YZ成立,这条规则称为(D )A.自反律B.传递律`C.伪传递律D.增广律10.能够消除多值依赖引起的冗余是( D )A.1NF B.2NFC.3NF D.4NF二、填空题1.关系数据库设计理论,数据依赖范式和关系模式的规范化设计方法。

数据库第3章习题参考答案

数据库第3章习题参考答案

第3章习题解答1.选择题(1)表设计器的“允许空”单元格用于设置该字段是否可输入空值,实际上就是创建该字段的(D)约束。

A.主键B.外键C.NULL D.CHECK(2)下列关于表的叙述正确的是(C)。

A.只要用户表没有人使用,则可将其删除B.用户表可以隐藏C.系统表可以隐藏D.系统表可以删除(3)下列关于主关键字叙述正确的是( A )。

A.一个表可以没有主关键字B.只能将一个字段定义为主关键字C.如果一个表只有一个记录,则主关键字字段可以为空值D.都正确(4)下列关于关联叙述正确的是( C )。

A.可在两个表的不同数据类型的字段间创建关联B.可在两个表的不同数据类型的同名字段间创建关联C.可在两个表的相同数据类型的不同名称的字段间创建关联D.在创建关联时选择了级联更新相关的字段,则外键表中的字段值变化时,可自动修改主键表中的关联字段(5)CREATE TABLE语句(C )。

A.必须在数据表名称中指定表所属的数据库B.必须指明数据表的所有者C.指定的所有者和表名称组合起来在数据库中必须唯一D.省略数据表名称时,则自动创建一个本地临时表(6)删除表的语句是(A)。

A.Drop B.Alter C.Update D.Delete (7)数据完整性不包括(B )。

A.实体完整性B.列完整性C.域完整性D.用户自定义完整(8)下面关于Insert语句的说法正确的是(A )。

A.Insert一次只能插入一行的元组B.Insert只能插入不能修改C.Insert可以指定要插入到哪行D.Insert可以加Where条件(9)表数据的删除语句是( A )。

A.Delete B.Inser C.Update D.Alter (10)SQL数据定义语言中,表示外键约束的关键字是(B )。

A.Check B.Foreign Key C.Primary Key D.Unique2.填空题(1)数据通常存储在表中,表存储在数据库文件中,任何有相应权限的用户都可以对之进行操作。

3数据库基本操作习题与答案

3数据库基本操作习题与答案

第三章数据库基本操作一、选择题1. 如果需要给当前表增加一个字段,应使用的命令是________。

A) APPEND B) INSERTC) EDIT D) MODIFY STRU2. 设表文件及其索引已打开,为了确保指针定位在物理记录号为1的记录上,应该使用命令________。

A) SKIP 1 B) SKIP -1C) GO 1 D) GO TOP3. 要显示数据库中当前一条记录的内容,可使用命令________。

A) LIST B) BROWSEC) TYPE D) DISPLAY4. 在当前表中,查找第2个女同学的记录,应使用命令________。

A) LOCATE FOR 性别="女"B) LOCATE FOR 性别="女" NEXT 2C) LIST FOR 性别="女"CONTINUED) LOCATE FOR 性别="女"CONTINUE5. Visual FoxPro的数据库表之间可建立两种联系,它们是________。

A) 永久联系和临时联系B) 长期联系和短期联系C) 永久联系和短期联系D) 长期联系和临时联系6. 数据库表的索引中,字段值不能有重复的索引有________种。

A) 1 B) 2C) 3 D) 47. 建立表间临时关联的命令是________。

A) LET RELATION TO命令B) JOIN命令C) SET RELATION TO命令D) 以上都不是8. 通过关键字建立表间的临时关联的前提是________。

A) 父表必须索引并打开B) 子表必须索引并打开C) 两表必须索引并打开D) 两表都不必索引9. 查询设计器的“筛选”选项卡上,“插入”按钮的作用是________。

A) 用于增加查询输出字段B) 用于增加查询的表C) 用于增加查询去向D) 用于插入查询输出条件10. 在多工作区的操作中,如果选择了4,7,8号工作区并打开了相应的数据库,在命令窗口执行命令SELECT 0,其功能是________。

数据库概论第1-3章习题参考答案

数据库概论第1-3章习题参考答案

第1章绪论习题参考答案1、试述数据、数据库、数据库管理系统、数据库系统的概念。

(参见P3、4、5页)参考答案:描述事物的符号记录称为数据;数据库是长期储存在计算机内的、有组织的、可共享的数据集合;数据库管理系统是位于用户与操作系统之间的一层数据管理软件; 数据库系统是指在计算机系统中引入数据库后的系统,一般由数据库、数据库管理系统(及其开发工具)、应用系统、数据库管理员和用户构成。

2.使用数据库系统有什么好处?(参见P12页)参考答案:数据库系统使信息系统从以加工数据的程序为中心转向围绕共享的数据库为中心的阶段,这样既便于数据的集中管理,又有利于应用程序的研制和维护,提高了数据的利用率和相容性,提高了决策的可靠性。

3.试述文件系统与数据库系统的区别和联系。

(8、9、10页)参考答案:1)数据结构化是数据库与文件系统的根本区别。

在文件系统中,相互独立的文件的记录内部是有结构的,管其记录内部已有了某些结构,但记录之间没有联系。

数据库系统实现整体数据的结构化,是数据库的主要特征之一。

2)在文件系统中,数据的最小存取单位是记录,粒度不能细到数据项。

而在数据库系统中,存取数据的方式也很灵活,可以存取数据库中的某一个数据项、一组数据项一个记录或或一组记录。

3)文件系统中的文件是为某一特定应用服务的,文件的逻辑结构对该应用程序来说是优化的,因此要想对现有的数据再增加一些新的应用会很困难,系统不容易扩充。

而在数据库系统中数据不再针对某一应用,而是面向全组织,具有整体的结构化。

5.试述数据库系统的特点。

(9、10、11页)参考答案:数据结构化;数据的共享性高、冗余度低、易扩充;数据独立性高;数据由DBMS统一管理和控制。

6.数据库管理系统的主要功能有哪些? (4页)参考答案:数据定义功能、数据操纵功能、数据库的运行管理、数据库的建立和维护功能。

7.试述数据模型的概念(13页)、数据模型的作用、数据模型的三个要素。

数据库第3章习题解答PPT教学课件

数据库第3章习题解答PPT教学课件
UPDATE SPJ
SET SNO=‘S3’
WHERE SNO=‘S5’ AND JNO=‘J4’ AND PNO=‘P6’ 10)从供应商关系中删除S2的记录,并从供应情况关系中删除
SELECT SNO FROM SC WHERE CNO=‘k1’ AND
SNO IN (SELECT SNO FROM SC WHERE CNO=‘k5’);
2020/12/10
6
3.用SQL语句建立第二章习题5中的四个表:
供应商关系:S(SNO,SNAME,STATUS,CITY) 零件关系:P(PNO,PNAME,COLOR, WEIGHT) 工程项目关系:J(JNO,JNAME,CITY) 供应情况关系:SPJ(SNO,PNO,JNO,QTY)
18
5)找出上海厂商供应的所有零件号码 SELECT DISTINCT PNO FROM S, SPJ WHERE S.SNO=SPJ.SNO AND S.CITY=‘上海’;
SELECT DISTINCT PNO
FROM SPJ
WHERE SNO IN
(SELECT SNO
FROM S
WHERE S.CITY=‘上海’);
6)找出使用上海产的零件的工程名称
SELECT JNAME
FROM S, SPJ, J
WHERE S.SNO=SPJ.SNO AND J.JNO=SPJ.JNO AND
2020/12/10 S.CITY=‘上海’ ;
19
7)找出没有使用天津产的零件的工程号码
SELECT JNO FROM J WHERE JNO NOT IN
CREATE TABLE SPJ (SNO CHAR(4) NOT NULL,
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
解决通信双方如何获知传输开始和传输结束,以及
通信双方如何协调、如何配合。
3.7 画图说明异步通信中请求与回答有哪几种互 锁关系?
主设备 请 求 回 答
从设备
不互锁 半互锁 全互锁
3.8 为什么说半同步通信同时保留了同步通信和 异步通信的特点?

ห้องสมุดไป่ตู้
解:半同步通信既能像同步通信那样由统一时钟控 制,又能像异步通信那样允许传输时间不一致,因 此工作效率介于两者之间。
3.10 什么是总线标准?为什么要设置总线标准? 你知道目前流行的总线标准有哪些?什么叫 即插即用?哪些总线有这一特点?



总线标准:系统与各模块、模块与模块之间的一个 互连的标准界面。界面的任一方只需根据总线标准 的要求完成自身一方接口的功能要求,而无需了解 对方接口与总线连接要求。 总线标准的设置主要解决不同厂家各类模块化产品 的兼容问题; 目前流行的总线标准有:ISA、EISA、PCI 等; 即插即用:即任何扩展卡只要插入系统便可工作。 EISA、PCI、USB
习题讲解
第3章
作业
3.2、3.5 、3.10 3.7、3.8、3.15、3.16

3.2 总线如何分类?什么是系统总线?系统总 线又分为几类,它们各有何作用,是单向的, 还是双向的,他们与机器字长、存储字长、 存储单元有何关系? 答:总线的分类:
按数据传送方式:并行传输总线和串行传输总
线; 按总线的使用范围:计算机总线、测控总线、 网络通信总线等; 按连接部件:片内总线、系统总线和通信总线。
总线周期
完成一次总线操作的时间,包括申请分配阶段、寻
址阶段、传数阶段和结束阶段;
总线传输周期
总线上两个部件完成一次完整且可靠的信息传输时
间; 并不一定只包含4个时钟周期(这是针对同步通 信),对于其它方式如异步、半同步通信就不一定 了;
总线的通信控制 指总线传送过程中双方的时间配合方式;

3.16 在异步串行传送系统中,字符格式为:1 个起始位、8个数据位、1个校验位、2个终 止位。若要去每秒传送120个字符,试求传 送的波特率和比特率。

解: 字符位数 1+8+1+2 =12 bit
波特率 120×12=1440 波特
比特率

120×8=960 比特
1440×(8/12)=960比特
系统总线是指CPU、主存、I/O设备(通 过I/O接口)各大部件之间的信息传输线。
按系统总线传输信息不同,可分为3类:数 据总线、地址总线和控制总线。
数据总线:数据总线是用来传输个功能部件之间
的数据信息,它 是双向传输总线,其位数与机器 字长、存储字长有关,一般为8、16或32位。 地址总线:地址总线主要是用来指出数据总线上 的源数据或目的 数据在主存单元的地址或I/O设备 的地址,地址总线上的代码是用来指明CPU欲访 问的存储单元或I/O端口的地址,由CPU输出,是 单向的,地址线的位数与存储单元的个数有关, 如地址线有20根,则对应的存储单元个数为220。 控制总线:控制总线是用来发出各种控制信号的 传输线,其传 输是单向的。
3.15 在一个32位的总线系统中,总线的时钟 频率为66MHz,假设总线最短传输周期为4 个时钟周期,试计算总线的最大数据传输 率。若想提高数据传输率,可采取什么措 施? 方法1:参考例3.1 方法2:1)66/4=16.5(MHz) 2)32/8=4(B) 3)16.5*4=66(MBps)
3.5解释下列概念:总线的主设备(或主模块 )、总线的从设备(或从模块)、总线的传 输周期和总线的通信控制。 解:
总线的主设备(主模块)——指一次总线传输期
间,拥有总线控制权的设备(模块); 总线的从设备(从模块)——指一次总线传输期 间,配合主设备完成传输的设备(模块),它只 能被动接受主设备发来的命令;
相关文档
最新文档