数据库系统概念 第七版 中文答案 第2章 关系模型介绍

第2章 关系模型介绍

2.1 考虑图 2.17 中的员工数据库。这些关系上适当的主码是什么

Answer:

相应的主键如下所示:

2.2 考虑从 instructor dept_name 属性到  department 关系的外键约束请给出对这些关系的插入和删除的示例,使得它们破坏该外码约束。

Answer:

  • 插入元组:

(10111,  Ostrom, Economics,  110000)

对instructor表插入其中 department 表没有Economics,将违反外键约束

  • 删除元组:

(Biology, Watson, 90000)

department 表中,如果至少有一个student或 instructor 元组的 dept 名称 为 Biology,则会违反外键约束。

 

2.3  考虑 time_slot 关系。假设一个特定的时间片可以在一周之内出现不止一次,请解释为什么 day start_time 是这种关系的主码的一部分,而结束则不是。

Answer:

属性 day 和 start_time 是主键的一部分,因为一个特定的课程很可能会在不同的天数上课,甚至可能在一天内上多次课。然而, end_time 不是主键的一部分,因为一个特定时间和特定日期开始的课程不能在多个时间结束。

2.4  在图2.1中所示的instructor实例中,没有两位教师具有相同的姓名。由此可推断,姓名可以作为教师的超键(或主键)吗?

Answer:

不是的。对于教师表的这种可能情况,姓名是唯一的,但一般情况下可能并不总是这样(除非大学规定两位教师不能有相同的姓名,这是一个相当不太可能的场景)。.

2.5  首先执行"student""advisor"关系的笛卡尔积,然后根据谓词"s_id = ID"对结果执行选择操作,最后的结果是什么?(在关系代数的符号表示中,这个查询可以写成:σ(s_id = ID) (student advisor))

Answer:

 结果中包含所有student属性的值,后跟所有advisor的属性。

 对于每个有advisor的学生,结果都有一行该嘘声的属性,后跟一个s_id,该属性与学生的id属性相同,然后是i_id。

 没有advisor 的学生不会出现在结果中。

 有多个advisor的属性将在结果中出现相应从次数

2.6  考虑图2.17的员工数据库。为以下每个查询提供一个关系代数表达式。:

a.     找到居住在城市“Miami”的每个员工的名字.

b.     找到每个工资大于$100,000的员工的名字

 c.   找到每个居住在“Miami”并且工资大于$100,000的员工的名字。

Answer:

 

2.7      考虑图2.18的银行数据库。为以下每个查询提供一个关系代数表达式。

a. 找到位于“Chicago”的每个分行的名称。.

b. 找到在分行“Downtown”有贷款的每个借款人的ID

Answer:

 

2.8      请提出以下每个查询的关系代数表达式,考虑图2.17的员工数据库。

a. 找到每个不在“BigBank”工作的员工的ID和姓名。

b. 请找出至少与数据库中每位职员的薪水同样多的所有职员的ID和姓名。.

Answer:

a.要找到不在BigBank工作的员工,首先找到所有在BigBank工作的员工。这正是不在期望结果中的员工。然后,我们使用集合差异找到所有员工的集合减去不应在结果中的那些员工。

b. 我们使用与第一部分相同的方法,首先找到那些没有获得最高工资的员工,或者换句话说,有其他员工获得更多工资的员工。由于这涉及比较两个员工的工资值,我们需要两次引用员工关系,因此需要使用重命名。.

2.9 关系代数的除法运算符÷的定义如下。设r(R)s(S)代表关系,且S R,即模式S的每个属性也在模式R中。给定一个元组t,令t[S]表示元组tS属性上的投影。然后r ÷s 是在模式 R - S上的关系(即在包含模式R中所有不在模式 S中的属性)。元组tr ÷ s中当且仅当满足两个条件:

以上设计:

a. 使用除法运算符编写关系代数表达式,找到所有已经修读所有计算机科学课程的学生的ID。(提示:使用投影操作选择仅包含ID和课程ID的元组,并使用选择表达式生成所有计算机科学课程ID的集合,然后进行除法运算。)

b. 展示如何在关系代数中编写上述查询,而不使用除法运算符。(通过这样做,您将展示如何使用其他关系代数操作来定义除法运算。)

Answer:

a.  

b. 您需要的表达式如下:

  • 26
    点赞
  • 53
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
数据库系统概念(杨冬青)习题答案Chapter 1 provides a general overview of the nature and purpose of database systems. The most important concept in this chapter is that database systems allow data to be treated at a high level of abstraction. Thus, database systems differsignificantly from the file systemsand general purpose programming environments with which students are already familiar. Another important aspect of the chapter is to provide motivation for the use of database systems as opposed to application programs built on top of file systems. Thus, the chapter motivates what the student will be studying in the rest of the course. The idea of abstraction in database systems deserves emphasis throughout, not just in discussion of Section 1.3. The overview of the structure of databases is, of necessity, rather brief, and is meant only to give the student a rough idea of some of the concepts. The student may not initially be able to fully appreciate the concepts described here, but should be able to do so by the end of the course. The specifics of the E-R, relational, and object-oriented models are covered in later chapters. These models can be used in Chapter 1 to reinforce the concept of abstraction, with syntactic details deferred to later in the course. If students have already had a course in operating systems, it is worthwhile to point out how the OS and DBMS are related. It is useful also to differentiate between concurrency as it is taught in operating systems courses (with an orientation towardsfiles, processes,and physical resources)and database concurrency control (with an orientation towards granularity finer than the file level, recoverable transactions, and resources accessed associatively rather than physically). If students are familiar with a particular operating system, that OS’s approach to concurrent file access may be used for illustration.

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值