数据库二三章习题参考
数据库原理及应用教程第3版课后题答案

第一章习题参考答案一、选择题1. C2. B3. D4. C5. D6. A7. A8. B9. D 10. B 11. C 12. D 13. A 14. D 15. B16. C 17. D 18. A 19. D 20. A二、填空题1. 数据库系统阶段2. 关系3. 物理独立性4. 操作系统5. 数据库管理系统(DBMS)6. 一对多7. 独立性8. 完整性控制9. 逻辑独立性10. 关系模型11. 概念结构(逻辑)12. 树有向图二维表嵌套和递归13. 宿主语言(或主语言)14. 数据字典15. 单用户结构主从式结构分布式结构客户/服务器结构浏览器/服务器结构第2章习题参考答案一、选择题1. A2. C3. C4. B5. B6. C7. B8. D9. C 10. A11. B 12. A 13. A 14. D 15. D二、填空题1. 选择(选取)2. 交3. 相容(或是同类关系)4. 并差笛卡尔积选择投影5. 并差交笛卡尔积6. 选择投影连接7. σf(R)8. 关系代数关系演算9. 属性10. 同质11. 参照完整性12. 系编号,系名称,电话办公地点13. 元组关系域关系14. 主键外部关系键15. R和S没有公共的属性第3章习题参考答案一、选择题1. B2. A3. C4. B5. C6. C7. B8. D9. A 10. D二、填空题结构化查询语言(Structured Query Language)数据查询、数据定义、数据操纵、数据控制外模式、模式、内模式数据库、事务日志NULL/NOT NULL、UNIQUE约束、PRIMARY KEY约束、FOREIGN KEY约束、CHECK约束聚集索引、非聚集索引连接字段行数定义系统权限、对象权限基本表、视图12.(1)INSERT INTO S VALUES('990010','李国栋','男',19)(2)INSERT INTO S(No,Name) VALUES('990011', '王大友')(3)UPDATE S SET Name='陈平' WHERE No='990009'(4)DELETE FROM S WHERE No='990008'(5)DELETE FROM S WHERE Name LIKE '陈%' 13.CHAR(8) NOT NULL14.SCo=Co15.ALTER TABLE StudentADDSGrade CHAR(10)第4章习题参考答案一、选择题1. B2. B3. D4. B5. C6. D7. B8. D9. C 10. A二、填空题1. 超键(或超码)2. 正确完备3. 属性集X的闭包X + 函数依赖集F的闭包F +4. 平凡的函数依赖自反性5. {AD→C} φ6. 2NF 3NF BCNF7. 无损连接保持函数依赖8. AB BC BD9. B→φ B→B B→C B→BC10. B→C A→D D→C11. AB 1NF12. AD 3NF第5章习题参考答案一、选择题1. B2. B3. C4. A5. C6. D7. A8. C9. D 10. D11. B 12. B 13. A 14. D 15. A二、填空题1、安全性控制、完整性控制、并发性控制、数据库恢复2、数据对象、操作类型3、授权粒度、授权表中允许的登记项的范围4、原始数据(或明文)、不可直接识别的格式(或密文)、密文5、事务、原子性、一致性、隔离性、持久性6、丢失更新、污读、不可重读7、封锁、排它型封锁、共享封锁8、利用数据的冗余9、登记日志文件、数据转储10、事务故障、系统故障、介质故障11、完整性12、登录账号、用户账号13、public14、服务器、数据库第6章习题参考答案一、选择题1. B2. C3. C4. A5. C6. B7. C8. B9. D 10. C11. D 12. B 13. B 14. D二、填空题1、数据库的结构设计、数据库的行为设计2、新奥尔良法3、分析和设计阶段、实现和运行阶段4、需求分析5、概念结构设计6、自顶向下、自底向上7、属性冲突、命名冲突、结构冲突8、逻辑结构设计9、确定物理结构、评价物理结构10、数据库加载11、运行和维护12、物理13、数据字典14、需求分析15、载入第7章习题参考答案一、选择题1. B2.C3.B4.D5.A二、填空题1.局部变量、全局变量2.- -、/*……*/3.DECLARE4.SQL、流程控制5.AFTER 触发器、INSTEAD OF 触发器6.插入表、删除表7.数据库备份、事务日志备份、差异备份、文件和文件组备份8.简单还原、完全还原、批日志还原9.硬盘、磁带、管道。
数据库第三章所有例题参考答案

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-3章习题参考答案

a bc
ab
ab
ad
c bd
c bd
da
cb
da
13、设有属性A、B、C、D,以下表示中不是关系的 是( )。
A.R(A) B.R(A,B,C,D) C.R(AXBXCXD) D.R(A,B)
14.如果一个关系的元组个数是无限的,称为 ( )。
A.无穷关系 B.无限关系 C.有限关系 D.安全
第二章 习题
RS S R S R S
B<B
ABC
R 123 226 314
BCD
234
S235 162 541
四、计算题
第二章 习题
4、将关系代数中5种基本运算用元组关 系演算表达式表示(假设R和S都为属 性名相同的二元关系)。
1>. RS=
2> R-S =
3> R x S =
4> 2 (R) =
5> F (R) =
指出关系S中违反关系完整性规则的元组是( )。
A.(1,2) B.(2,null) C.(3,3) D.(4,1)
第二章 习题
单项选择题
12、设有关系R(A,B,C),经操作A,B ( B=‘b’ (R))的
运算结果是 ( )。
A BC
R: a b c
A:
B:
A BC A B
C:
AB
D:
AB
d af
2、在实体中有属性可作为键而选定其中一个时,称
为该实体的 ( )。 A.外部键 B.候选键 C.主键 D.主属性
3、若某属性虽非该实体的主键,却是另一实体的主
键,称该属性为( )。 A.外部键 B.候选键 C.主键 D.主属性
数据库 第三章习题参考答案

三、设计题1.(1)SELECT BAuth FROM Book, PublishWHERE Book.PNo= Publish.PNo AND BName=’操作系统’ AND PName=’高等教育出版社’(2)查找为作者“张欣”出版全部“小说”类图书的出版社的电话。
SELECT PTel FROM Book, PublishWHERE Book.PNo= Publish.PNo AND BType =’小说’ AND BAuth=’张欣’(3)查询“电子工业出版社”出版的“计算机”类图书的价格,同时输出出版社名称及图书类别。
SELECT BPrice, PName, BType FROM Book, PublishWHERE Book.PNo= Publish.PNo AND PName =’电子工业出版社’ AND BType =’计算机’(4)查找比“人民邮电出版社”出版的“高等数学”价格低的同名书的有关信息。
SELECT * FROM BookWHERE BName =’高等数学’AND BPrice<ANY(SELECT BPrice FROM Book,PublishWHERE Book.PNo= Publish.PNo AND PName =’人民邮电出版社’ AND BName =’高等数学’)AND PName <>’人民邮电出版社’(5)查找书名中有“计算机”一词的图书的书名及作者。
SELECT BName, BAuth FROM BookWHERE BName LIKE’%计算机%’(6)在“图书”表中增加“出版时间”(BDate)项,其数据类型为日期型。
ALTER TABLE BookADD BDate datetime(7)在“图书”表中以“作者”建立一个索引。
CREATE INDEX Name ON Book(BAuth) desc2.(1)建立存书表和销售表。
数据库第二章课后习题解答

第3部分习题及其解答第一章的两道题3-2 习题22.6 分别把习题1.10、习题1.11的ER图转换成关系模型数据结构。
【参考答案】1.习题1.10的ER图可转换成如下的关系模型数据结构。
①程序员(编号,姓名,性别,年龄,单位,职称),其中编号是关键字;②程序(程序名称,版权,专利号,价格),其中程序名称是关键字;③设计(编号,程序名称,开始时间,结束时间),其中(编号,程序名称)是关键字。
2.习题1.11的ER图可转换成如下的关系模型数据结构。
①工厂(工厂名称,厂址,联系电话),其中工厂名称是关键字;②产品(产品号,产品名,规格,单价),其中产品号是关键字;③工人(工人编号,姓名,性别,职称,工厂名称,雇用期,月薪),其中工人编号是关键字,工厂名称是外关键字,雇用期和月薪是联系属性;④生产(工厂名称,产品号,月产量),其中(工厂名称,产品号)是关键字,生产关系是表示联系的。
2.8 判断下列情况,分别指出它们具体遵循那一类完整性约束规则?1.用户写一条语句明确指定月份数据在1~12之间有效。
2.关系数据库中不允许主键值为空的元组存在。
3.从A关系的外键出发去找B关系中的记录,必须能找到。
【解答】1.用户用语句指定月份数据在1~12之间有效,遵循用户定义的完整性约束规则。
2.关系数据库中不允许主键值为空的元组存在,遵循实体完整性约束规则;3.从A关系的外键出发去找B关系的记录,必须能找到,遵循引用完整性约束规则。
2.9 判断下列情况,分别指出他们是用DML还是用DDL来完成下列操作?1.创建“学生”表结构。
2.对“学生”表中的学号属性,其数据类型由“整型”修改为“字符型”。
3.把“学生”表中学号“021”修改为“025”。
【解答】1.创建“学生”表结构,即定义一个关系模式,用DDL 完成。
2.修改“学生”表中学号属性的数据类型,即修改关系模式的定义,用DDL 完成。
3.修改“学生”表中学号属性的数据值,即对表中的数据进行操作,用DML 完成。
【精选】数据库第三章课后习题

• 14、 • (1)GRANT SELECT ON 职工,部门TO 王明 • (2) GRANT INSERT,DELETE ON 职工,部门TO
李勇
• (3) GRANT SELECT ON 职工WHEN USER() = NAME TO ALL
• (4) GRANT SELECT,UPDATE(工资) ON 职工 TO 刘星
• 7、视图的优点 • 视图能够简化用户的操作 • 视图使用户能以多种角度看待同一数据 • 视图对重构数据库提供了一定程度的逻辑
独立性; • 视图能够对机密数据提供安全保护。
• 8、所有的视图是否都可以更新?
• 不是。视图是不实际存储数据的虚表,因 此对视图的更新,最终要转换为对基本表 的更新。因为有些视图的更新不能惟一有 意义地转换成对相应基本表的更新,所以 ,并不是所有的视图都是可更新的。
SPJ TO 李天明;
• 13、 • (1)INSERT INTO SC(Sno,Cno,Grade)
VALUES("2000012", "1128", NULL); • (2)SELECT Sno,Cno
FROM SC
WHERE Grade IS NULL;
• (3)SELECT cname,grade FROM course,Sc WHERE o=o AND cname="英语"
• (1) SELECT DIST PNO,QTY FROM SPQ
• (2) SELECT DIST * FROM SPQ WHERE SNO="S1‘
• 12、 • (1)GRANT INSERT
ON TABLE S TO 张勇
数据库习题参考答案123章

习题参考答案第1章一、填空题1.答案:【1】分类【2】组织【3】存储【4】检索【5】维护2.答案:【1】逻辑结构【2】存储空间【3】数据存取方法3.答案:【1】数据冗余【2】不一致性【3】数据联系弱4.答案:【1】应用程序【2】数据5.答案:【1】1968年【2】Information Management System【3】层次6.答案:【1】记录7.答案:【1】数据的完整性【2】数据的安全性【3】并发控制、【4】数据库的恢复8.答案:【1】数据项【2】记录9.答案:【1】概念模型【2】数据模型10.答案:【1】数据结构【2】数据操作【3】数据的完备性约束条件11.答案:【1】层次数据库【2】网状数据库【3】关系数据库、【4】面向对象的数据库12.答案:【1】实体内部的联系【2】实体与实体之间的联系13.答案:【1】一对一的联系【2】一对多的联系【3】多对多的联系14.答案:【1】三级模式【2】子模式【3】模式【4】存储模式15.答案:【1】数据库【2】硬件【3】软件【4】数据库管理员(DBA)16.答案:【1】数据库管理员【2】系统分析员【3】应用程序员【4】用户二、选择题1.C 2.C 3.A 4.A 5.C 6.B 7.A①B⑤C⑦D④E③8.D9.C 10.B 11.C 12.A三、简答题1.参照1.2.1数据库发展阶段的划分。
2.答案一:数据库是集中、统一地保存和管理某一单位或某一领域内所有有用信息的系统。
这个系统根据数据之间的自然联系结构而成,数据冗余较少,且具有较高的数据独立性,能为多种应用服务。
答案二:数据库是以一定的组织方式存储在一起的、能为多个用户共享的、具有尽可能小的冗余度、与应用彼此独立的、相互关联的数据集合。
3.数据结构指数据的组织方式,包括物理方式与逻辑方式。
数据字典(简称DD)是对系统中数据的详尽描述,是各类数据属性的清单。
在RDBMS中,数据字典通常采用和普通数据同样的表示方式,DD在需求分析阶段建立,在数据库设计过程中不断修改、充实和完善。
数据库第一、二、三章课后习题答案

第一章习题1.试述数据、数据库、数据库系统、数据库管理系统的概念。
答:(1)数据(Data):描述事物的符号记录称为数据。
数据的种类有数字、文字、图形、图像、声音、正文等。
数据与其语义是不可分的。
(2)数据库(D砒aBase,简称DB):数据库是长期储存在计算机内的、有组织的、可共享的数据集合。
数据库中的数据按一定的数据模型组织、描述和储存,具有较小的冗余度、较高的数据独立性和易扩展性,并可为各种用户共享。
(3)数据库系统(DataBase Sytem,简称DBS):数据库系统是指在计算机系统中引入数据库后的系统构成,一般由数据库、数据库管理系统(及其开发工具)、应用系统、数据库管理员构成。
(4)数据库管理系统(DataBase Management Sytem,简称DBMS):数据库管理系统是位于用户与操作系统之间的一层数据管理软件,用于科学地组织和存储数据、高效地获取和维护数据。
DBMS的主要功能包括数据定义功能、数据操纵功能、数据库的运行管理功能、数据库的建立和维护功能。
2.试述数据管理技术的发展过程。
答:从数据管理的角度看,数据库技术到目前共经历了人工管理阶段、文件系统阶段和数据库系统阶段。
人工管理阶段数据管理特点:数据不保存,没有对数据进行管理的软件系统,没有文件的概念,数据不具有独立性。
文件系统阶段数据管理特点:数据可以长期保存,由文件系统管理数据,文件的形式已经多样化,数据具有一定的独立性。
数据库系统阶段数据管理特点:采用复杂的结构化的数据模型,较高的数据独立性,最低的冗余度,数据控制功能3.文件系统与数据库系统有什么区别和联系?答:文件系统和数据库系统之间的区别。
(1)文件系统用文件将数据长期保存在外存上,数据库系统用数据库统一存储数据;(2)文件系统中的程序和数据有一定的联系,数据库系统中的程序和数据分离;(3)文件系统用操作系统中的存取方法对数据进行管理,数据库系统用DBMS统一管理和控制数据;(4)文件系统实现以文件为单位的数据共享,数据库系统实现以记录和字段为单位的数据共享。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
第二章数据模型与概念模型
1、试叙述数据库、数据库管理系统、数据库系统三个概念的含义和联系。
(1)数据库是一个按数据结构来存储和管理数据的计算机软件系统。
(2)数据库管理系统是专门用于管理数据库的计算机系统软件。
(3)数据库系统是指带有数据库并利用数据库技术进行数据管理的计算机系统。
2、试举出三个实例,要求实体型之间分别有一对一,一对多,多对多的联系。
(1)在一所学校里面只有一位校长,而校长只能在一所学校里任职,则学校与校长之间具有一对一联系。
(2)一座圆林里有多棵树,而每棵树只能在一座圆林里生长,则圆林与树之间具有一对多的联系。
(3)学校的每门课程可以有多名学生选修,而学生也可以选修多门课程,则课程与学生之间具有多对多的联系。
3、主要的数据模型有哪几种?如何完整的描述一个数据模型。
(1)主要的数据模型有层次模型、网状模型和关系模型。
(2)完整的描述一个数据模型要从它的三要素开始,即描述它的数据结构、数据操作和完整性约束条件。
第三章数据库系统的设计方法(一)
18现有一个局部应用,包括两个实体,“出版社”和“作者”,这两个实体都是多对多的联系,请设计适当的属性,画出E-R图,并转换为关系模型。
关系模型:
作者(作者编号,住址,身份证号,年龄,姓名,手机号)
出版社(社长名字,名称,出版社号,电话,地址)
出版(书名,书的数量,出版社号,作者号)
19请设计一个图书馆数据库,此数据库中对每个借阅者保存记录,包括:读者号、姓名、地址、性别、年龄、单位。
对每本书保存有:书号、书名、作者、出版社。
对每本借出的书保存有:读者号、借出日期和应还日期。
要求:给出该图书馆数据库的E-R图,再将其转化为关系模型。
关系模型:
书(书名,出版社,书号,作者)
借阅者(姓名,单位,读者号,地址,年龄,性别)
借出(读者号,借出日期,应还日期)
20教材第三章图3-41是某个教务管理数据库的E-R图,请将他们转换成关系模型。
关系模型:
学生(学号,姓名,系别,年龄)
教师(教师号,姓名,系别,教研组)
教学(学号,教师号)
选课(学生号,课号,成绩)
教课(教师号,课号)
课程(课号,课程名,选修课)
第三章数据库系统的设计方法(二)
22.
设有一家百货商店,已知信息如下。
1)每个职工的数据是职工号、姓名、地址和他所在的商品部。
2)每一商品部的数据有:它的职工,经理和它经销的商品。
3)每种经销的商品数据有:商品名、生产厂家、价格、型号(厂家定的)和内部商品代号(商店定的)。
4)每个生产厂家的数据有:厂名、地址、向商店提供的价格。
请设计该百货商店的概念模型,再将概念模型转换为关系模型。
注意某些信息可用属性表示,其他信息可用联系表示。
概念模型:
关系模型:
职工(职工号,姓名,地址)
商品部(商品部编号,商品部名)
经理(经理编号,经理名)
商品(内部商品编号,型号,价格,商品名)
厂家(厂编号,厂名,地址)
工作(职工号,商品编号)
负责(经理编号,商品部编号)
销售(商品部编号,内部商品编号)
生产(厂编号,型号)
23.
设有如下实体。
学生:学号、单位、姓名、性别、年龄、选修课程名
课程:编号、课程名、开课单位、任课教师号
教师:教师号、姓名、性别、职称、讲授课程编号
单位:单位名称、电话、教师号、教师名
上述实体中存在如下联系。
1)一个学生可选修多门课程,一门课程可为多个学生选修。
2)一个教师可讲授多门课程,一门课程可为多个教师讲授。
3)一个单位可有多个教师,一个教师只能属于一个单位。
试完成如下工作。
1)分别设计学生选课和教师任课两个局部信息的结构E-R图。
2)将上述设计完成的E-R图合并成一个全局E-R图。
3)将该全局E-R图转换为等价的关系模型表示的数据库逻辑结构。
1)学生选课E-R图
教师任课E-R图
2)
全局E-R
3)
全局E-R图转换为等价的关系模型表示的数据库逻辑结构教师(教师号,职称,姓名,性别)
学生(学号,姓名,性别,年龄)
课程(编号,课程名)
开设(单位名,课程编号)讲授(教师号,课程编号)任职(单位名,教师号)学习(单位名,课程编号)。