数据库系统概念第六版(机械工业出版社) 第四章 中级SQL 实践习题 部分习题

数据库系统概念第六版(机械工业出版社) 第四章 中级SQL 实践习题 部分习题
部分习题:
4.12

select employee_name
from employee natural left outer join manages
where manager_name is NULL;

4.13
course的属性title不匹配(student全外连接takes)的所有元组,由于是全外连接,所以添null
4.14

create view tot_credits(year,num_credits)
as 
(select year,sum(credits)
from takes natural join course
group by year)

4.17
保证安全性

实践习题:
英文原版答案:
4.1 Write the following queries in SQL:
a. Display a list of all instructors, showing their ID, name, and the number of sections that they have taught. Make sure to show the number of sections as 0 for instructors who have not taught any section. Your query should use an outerjoin, and should not use scalar subqueries. b. Write the same query as above, but using a scalar subquery, without outerjoin. c. Display the list of all course sections offered in Spring 2010, along with the names of the instructors teaching the section. If a section has morethan one instructor, itshould appearas many timesin the result as it has instructors. If it does not have any instructor, it should still appear in the result with the instructor name set to “—”. d. Displaythelistofalldepartments,withthetotalnumberofinstructors in each department, without using scalar subqueries. Make sure to correctly handle departments with no instructors.
Answer:
a. Display a list of all instructors, showing their ID, name, and the number of sections that they have taught. Make sure to show the number of sections as 0 for instructors who have not taught any section. Your query should use an outerjoin, and should not use scalar subqueries.
select ID, name, count(course id, section id, year,semester) as ’Number of sections’ from instructor natural left outer join teaches group by ID, name
The above query should not be written using count(*) since count * counts null values also. It could be written using count(section id), or

any other attribute from teaches which does not occur in instructor, which would be correct although it may be confusing to the reader. (Attributes that occur in instructor would not be null even if the instructor has not taught any section.) b. Write the same query as above, but using a scalar subquery, without outerjoin.
select ID, name, (select count(*) as ’Number of sections’ from teaches T where T.id = I.id) from instructor I
c. Display the list of all course sections offered in Spring 2010,

  • 5
    点赞
  • 38
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: 《数据库系统概念第六版pdf》是一本经典的数据库理论教材。本书系统地介绍了数据库系统的基本概念SQL语言、数据模型、数据管理技术等内容。本书的特点是理论联系实践,强调数据库应用的实际场景,且涵盖了最新的数据库技术和概念。 本书主要分为八个章节,每个章节都是有机结合的,内容相互关联,从而构建一个关于数据库系统的完整知识体系。其中,第一章为引言,介绍了数据库的概念和发展历史。第二章介绍了关系模型,包括关系代数、SQL语言、实体关系图等。第三章介绍关系数据库设计的基本原则和步骤,包括ER图、范式设计等。第四章介绍了关系数据完整性和安全性的管理,包括数据约束、授权与角色等。第五章介绍了多表查询和关联查询的使用技巧。第六章介绍了SQL语言的高级特性,如嵌套查询、视图、事务等。第七章介绍了高级数据管理技术,如数据仓库、数据挖掘等。最后一章讨论了高可用性、分布式数据库、NoSQL等主题。 本书的编排清晰、内容全面,对于广大数据库从业者和学生都是一本非常优秀的教材。务实性的描述,让读者更容易理解。文字流畅且通俗易懂,例子或练习题更是帮助读者快速掌握。总体来说,这是一本被广泛认可和推荐的数据库教材。 ### 回答2: 《数据库系统概念第六版PDF》是一本深入介绍数据库系统理论和实践的学术著作,其主要内容包括数据库系统概述、关系模型、数据库语言SQL、关系数据库设计、关系数据库编程和应用等多个方面。 该书的内容涵盖了从数据库设计、实现到运行管理的全过程,对于需要从事数据库相关工作的人员具有非常实用的指导意义。同时,该书也提供了一些典型的数据库设计案例,作者讲述了如何在具体业务场景下进行数据库设计,并进行的详细解释和说明。这些案例不仅适用于初学者的实践训练,也可以为专业人士提供宝贵的参考和借鉴。 总之,《数据库系统概念第六版PDF》是一本综合性、深入剖析且具有实用性的数据库相关著作。无论是想要从事数据库相关的人员,还是已经从事多年的专业人士,都可以从这本书中获取到对数据库理论和实践的增长、更新和加强。 ### 回答3: 《数据库系统概念第六版》是一本有关数据库系统概念和实现的经典教材。本书内容涵盖了数据库的基本概念,关系模型,关系代数和SQL语言,不同类型的数据模型(如面向对象、XML),事务管理和并发控制,数据仓库和数据挖掘等方面。作者以通俗易懂的方式,详细阐述了数据库系统的各个方面,使得读者能够理解数据库的基本原理和技术细节,从而能够更好地应用它们。 本书特点在于其广泛的覆盖面和深入的讲解。书中涵盖的内容包含了数据库系统的各个领域和各个方面,包括基础理论、数据库设计、SQL语言、数据仓库与数据挖掘、事务处理、并发控制等。从此,读者可以全面掌握数据库的概念、基本原理和实际应用。此外,本书还特别强调了实践操作和案例研究,通过大量的实例和练习,帮助读者获得实践经验和实际应用能力。 总之,《数据库系统概念第六版》是一本非常优秀而且值得一读的数据库相关教材。它不仅适合计算机专业的大学生和研究生使用,也适合相关工作者阅读,增进其对数据库系统的理解和掌握,从而更好地应用和发挥它们的作用。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值