database第3章 第1次课

合集下载

数据库基础教程

数据库基础教程

11
三、为什么用数据库
数据库方法能较好地解决以上的问题
数据的独立性 有效地访问数据 减少应用程序的开发时间 数据的一致性和安全性 统一的数据管理 并发的数据访问
12
四、数据库模型的发展
几种模型:
基于树的层次模型 定长记录 基于图的网状模型 物理相关、无高级查询语言 基于表的关系模型 物理无关、支持高级查询语言, 基于对象的面向对象模型 OO OR
存储管理程序
文件管理程序 缓冲区管理查程序
18
DBMS的组成
查询处理程序
查询优化 磁盘访问,是查询的主要代价; 索引是查询优化的利器
19
DBMS的组成
事务管理程序
事务:是用户定义的一个数据库操作序列 事务的四个特性 原子性A 一致性C 隔离性I 持久性D
20
DBMS的组成
客户-服务器程序体系结构 浏览器-服务器体系结构
3
参考
/ ~ullman/fcdb.html C.J.Date.《An Introduction to Database System (Ed.7)》 Raghu Ramakrishnan,Johannes Gehrke. 《Database Management Systems (Ed.2)》 萨师煊,王珊.《数据库系统概论(第三版)》
联系的多重性
N:N
在联系中,每个C都和D的集合有关,而在反向 联系中,每个D都和C的集合有关
N:1
在联系中,每个C都和唯一的D有关,而在反向 联系中,每个D都和C的集合有关
1:1
在联系中,每个C都和唯一的D有关,而在反向 联系中,每个D都和唯一的C有关
38
Interface Moive{ …… N relationship Set <Star> stars inverse Star :: staredIn; relationship Studio ownedBy N inverse Studio :: owns; }; Interface Star{ …… N relationship Set <Moive> staredIn inverse Moive :: stars; }; Interface Studio{ …… 1 relationship Set <Moive> owns inverse Moive :: ownedBy; };

数据库系统教程(何玉洁 李宝安 编著)第3章习题答案

数据库系统教程(何玉洁 李宝安 编著)第3章习题答案

第3章关系数据库习题答案1.试述关系模型的3个组成部分。

关系模型由关系模型的数据结构、关系模型的操作集合和关系模型的完整性约束3部分组成。

2.解释下列术语的含义:●笛卡尔积设A,B为集合,用A中元素为第一元素,B中元素为第二元素构成有序对,所有这样的有序对组成的集合叫做A与B的笛卡尔积,记作A×B。

●主键也称为主码或主关键字,是表中的属性或属性组,用于唯一地确定一个元组。

主键可由一个属性组成,也可由多个属性共同组成。

●候选键又称为候选码或候选关键字,是关系中能够唯一标识元组且不含有多余属性的一个属性或属性集的值。

一个关系上可有多个候选键。

●关系是笛卡尔积中有一定意义且有限的子集。

通俗讲关系就是二维表,表的名称就是关系的名称,表的每一行对应一个元组,表的每一列对应一个域。

●关系模式即二维表的结构,或者说是二维表的表框架或表头结构。

●关系数据库即对应于一个关系模型的所有关系的集合。

3.关系数据库的3个完整性约束是什么,各是什么含义?实体完整性指关系数据库中所有的表都必须有主键,且表中不允许存在无主键或主键值相同的记录,即主键约束。

参照完整性一般是指多个实体或关系之间的关联关系,即外键约束。

参照完整性规则定义了外键与被参照的主键间的引用规则,要求外键值为空或等于其所参照的关系中的某个元组的主键值。

用户定义的完整性是针对某一具体应用领域定义的数据约束条件,即对表中字段属性的约束,它反映某一具体应用所涉及的数据必须满足应用语义的要求。

通俗讲是指明关系中属性的域,限制关系中属性的取值类型及取值范围,防止属性的值与应用语义矛盾。

4.过程语言与非过程语言有什么区别?非过程语言主要用于基本的数据更新查询处理,过程语言可以编写存储过程,结构相对更复杂。

5.利用表3-11~表3-13所给的3个关系,试用关系代数表达式、Alpha语言完成下列查询:表3-11表3-12表3-131)查询“信息管理系”学生的选课情况,列出学号、姓名、课程号和成绩;∏Sno,Sname,Cno,Grade(σSdept=’信息管理系’(Student⋈Course⋈SC)) 2)查询“VB”课程的考试情况,列出学生姓名、所在系和考试成绩;∏Sname,Sept,Grade(σCname=’VB’(Student⋈Course⋈SC))3)查询考试成绩高于90分的学生的姓名、课程名和成绩;∏Sname,Cname,Grade(σGrade>90(Student⋈Course⋈SC))4)查询至少选修了0821103号学生所选的全部课程的学生的姓名和所在系;∏Sname,Sdept(Student⋈(∏Sno,Cno(SC)÷∏Cno(SC)(σSno=’0821103’(SC))))5)查询至少选了“C001”和“C002”两门课程的学生的姓名、所在系和所选的课程号。

database 用法

database 用法

database用法一、简介Database(数据库)是一种用于存储、管理和检索数据的工具。

它是一种强大的技术,可以大大提高数据处理的效率和精度。

在许多领域,如商业、科研、教育等,数据库都发挥着至关重要的作用。

二、基本概念1.数据库管理系统(DBMS):DBMS是用于管理数据库的软件,它负责存储、检索、更新数据,以及执行其他与数据库相关的操作。

2.表:表是数据库的基本组成单位,它是一种数据结构,用于存储相关数据项。

3.列:列是表中的数据类型列表,如数字、文本、日期等。

4.记录:记录是表中的数据单元,用于存储具体信息。

5.查询:查询是用于检索数据库中数据的方法,可以通过指定条件、排序等来获取所需数据。

6.更新:更新是指对数据库中数据进行修改的操作。

7.删除:删除是指从数据库中移除数据的过程。

三、安装与配置1.下载和安装DBMS软件:根据所使用的数据库类型(如MySQL、Oracle、SQLServer等),下载并安装相应的DBMS软件。

2.配置数据库连接:根据所使用的编程语言和框架,配置数据库连接,以便于与数据库进行通信。

3.创建数据库和表:使用DBMS的管理工具或编程接口,创建所需的数据库和表。

四、基本操作1.插入数据:将数据插入到表中。

2.查询数据:检索符合特定条件的数据。

3.更新数据:修改表中的数据。

4.删除数据:从表中移除数据。

5.执行SQL语句:SQL(结构化查询语言)是用于操作数据库的标准语言。

它可以用于执行各种数据库操作,如查询、插入、更新和删除数据。

6.使用编程语言访问数据库:许多编程语言提供了访问数据库的接口和库,如Python的MySQLConnector、Java的JDBC等。

通过这些接口和库,可以更方便地与数据库进行交互。

五、常见问题及解决方案1.连接问题:检查网络连接、防火墙设置、数据库服务是否启动等,以确保能够正常连接到数据库服务器。

2.数据插入错误:检查数据类型是否匹配、是否有语法错误等。

数据库第三章习题参考答案范文大全

数据库第三章习题参考答案范文大全

数据库第三章习题参考答案范文大全第一篇:数据库第三章习题参考答案3-2 对于教务管理数据库的三个基本表S(SNO,SNAME, SEX, AGE,SDEPT) SC(SNO,CNO,GRADE)C(CNO,CNAME,CDEPT,TNAME) 试用SQL的查询语句表达下列查询:⑴ 检索LIU老师所授课程的课程号和课程名。

⑵ 检索年龄大于23岁的男学生的学号和姓名。

⑶ 检索学号为200915146的学生所学课程的课程名和任课教师名。

⑷ 检索至少选修LIU老师所授课程中一门课程的女学生姓名。

⑸ 检索WANG同学不学的课程的课程号。

⑹ 检索至少选修两门课程的学生学号。

⑺ 检索全部学生都选修的课程的课程号与课程名。

⑻ 检索选修课程包含LIU老师所授课程的学生学号。

解:⑴ SELECT C#,CNAME FROM C WHERE TEACHER=’LIU’; ⑵ SELECT S#,SNAME FROM S WHERE AGE>23 AND SEX=’M’; ⑶ SELECT CNAME,TEACHER FROM SC,C WHERE SC.C#=C.C# AND S#=’200915146’ ⑷ SELECT SNAME (连接查询方式) FROM S,SC,C WHERE S.S#=SC.S# AND SC.C#=C.C# AND TEACHER=’LIU’;或:SELECT SNAME (嵌套查询方式) FROM S WHERE SEX=’F’AND S# IN (SELECT S# FROM SC WHERE C# IN (SELECT C# FROM C WHERE TEACHER=’LIU’)) 或:SELECT SNAME (存在量词方式)SEX=’F’ AND FROM S WHERE SEX=’F’ AND EXISTS(SELECT* FROM SC WHERE SC.S#=S.S# AND EXISTS(SELECT * FROM C WHERE C.C#=SC.C# AND TEACHER=’LIU’)) ⑸ SELECT C# FROM C WHERE NOT EXISTS(SELECT * FROM S,SC WHERE S.S#=SC.S# AND SC.C#=C.C# AND SNAME=’WANG)); ⑹ SELECT DISTINCT X.S# FROM SC AS X,SC AS Y WHERE X.S#=Y.S# AND X.C#!=Y.C#; ⑺ SELECT C#.CNAME FROM C WHERE NOT EXISTS (SELECT * FROM S WHERE NOT EXISTS (SELECT * FROM SC WHERE S#=S.S# AND C#=C.C#)); ⑻ SELECT DISTINCT S# FROM SC AS X WHERE NOT EXISTIS (SELECT * FROM C WHERE TEACHER=’LIU’ AND NOT EXISTS (SELECT * FROM SC AS Y WHERE Y.S#=X.S# AND Y.C#=C.C#)); 3-3 试用SQL查询语句表达下列对3.2题中教务管理数据库的三个基本表S、SC、C查询:⑴ 统计有学生选修的课程门数。

数据库基础教程(完整版)

数据库基础教程(完整版)

数据库基础教程(完整版)第一部分:认识数据库数据库,顾名思义,就是一个用来存储、管理数据的仓库。

在这个信息爆炸的时代,数据已经成为了企业的核心资产,而数据库就是管理这些资产的重要工具。

无论是电商平台、社交媒体,还是企业内部的管理系统,都离不开数据库的支持。

一、数据库的分类1. 关系型数据库:以表的形式组织数据,每个表由行和列组成,行代表记录,列代表字段。

常见的有MySQL、Oracle、SQL Server等。

2. 非关系型数据库:与关系型数据库不同,非关系型数据库的数据结构更加灵活,常见的有MongoDB、Redis、Cassandra等。

3. NoSQL数据库:NoSQL是Not Only SQL的缩写,表示不仅仅是SQL,它包含了非关系型数据库以及一些新型的数据库技术,如NewSQL 等。

二、数据库的组成1. 数据库管理系统(DBMS):负责管理和维护数据库的软件系统,如MySQL、Oracle等。

2. 数据库:存储数据的仓库,由多个表组成。

3. 表:数据库中的基本单位,由行和列组成,行代表记录,列代表字段。

4. 记录:表中的一行数据,代表一个完整的信息。

5. 字段:表中的一列数据,代表记录中的一个属性。

三、数据库的作用1. 数据存储:将数据存储在数据库中,方便管理和查询。

2. 数据管理:通过数据库管理系统,可以对数据进行增删改查等操作。

3. 数据安全:数据库管理系统提供了数据备份、恢复、权限控制等功能,保障数据的安全。

4. 数据共享:多个用户可以同时访问数据库,实现数据共享。

5. 数据分析:通过数据库管理系统,可以对数据进行统计、分析等操作,为企业决策提供依据。

四、学习数据库的必要性1. 提高工作效率:掌握数据库技术,可以快速地处理大量数据,提高工作效率。

2. 适应市场需求:随着互联网的发展,数据库技术已经成为IT 行业的必备技能。

3. 拓展职业发展:学习数据库技术,可以为职业发展打下坚实的基础。

DATABASE ch3 SQL

DATABASE ch3 SQL

Course relation. SELECT Cname FROM Course
An asterisk in the select clause denotes
“all attributes”.
SELECT * FROM Course
NOTE: SQL names are case insensitive, meaning you can use upper case or lower case. Upper case is better and recommended.
Chapter 3 SQL
3.1 Data Definition Language 3.2 Data Query Language 3.3 Nested Subqueries 3.4 Joined Relations
3.5 Modification of the Database
3.21
2) The where Clause
SQL Includes a between comparison
operator in order to simplify where clauses that specify that a value be less than or equal to some value and greater than or equal to some other value.
PRIMARY KEY(Sid),
CHECK (Ssex in ('M','F')) );
3.6
2) Integrity Constraints in Create Table
Create table Course,and declare Cid as the

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

数据库第3章习题解答PPT教学课件
不能取空值。由于已规定供应商号为主码,所以对属性 SNO的定义中的“NOT NULL”可以省略不写。
CREATE TABLE S (SNO CHAR(4) NOT NULL ,
SNAME CHAR(20) NOT NULL,
STATUS CHAR(10),
CITY CHAR(20),
PRIMARY KEY (SNO));
CREATE TABLE SPJ (SNO CHAR(4) NOT NULL,
PNO CHAR(4) NOT NULL,
JNO CHAR(4) NOT NULL,
QTY SMALLINT,
PRIMARY KEY (SNO,PNO,JNO),
FOREIGN KEY (SNO) REFERENCES S(SNO),
2)求供应工程J1零件P1的供应商号码SNO; SELECT SNO FROM SPJ WHERE JNO=‘J1’ AND PNO=‘P1’;
3)求供应工程J1零件为红色的供应商号SNO; SELECT DISTINCT SNO FROM SPJ WHERE JNO=‘J1’ AND PNO IN (SELECT PNO FROM P WHERE COLOR=‘红’);
FOREIGN KEY (PNO) REFERENCES P(PNO),
2020/12/10
FOREIGN KEY (JNO) REFERENCES J(JNO)); 9
4.针对上题中建立的四个表试用SQL语言完成第二 章习题5中的查询
1)求供应工程J1零件的供应商号码SNO;
2)求供应工程J1零件P1的供应商号码SNO;
2020/12/10
3
(1) 检索“程军”老师所授课程的课程号CNO和课程名CNAME。

数据库原理及应用教程第3版课后题答案

数据库原理及应用教程第3版课后题答案

数据库原理及应用教程第3版课后题答案第一篇:数据库原理及应用教程第3版课后题答案第一章习题参考答案一、选择题1.C2.B3.D4.C5.D6.A7.A8.B9.D 10.B 11.C 12.D 13.A 14.D15.B 16.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.A 11.B 12.A 13.A 14.D15.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 NULL 14.o=o 15.ALTER TABLE Student ADD SGrade 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→BC 10.B→C A→D D→C 11.AB 1NF 12.AD 3NF第5章习题参考答案一、选择题1.B2.B3.C4.A5.C6.D7.A8.C9.D 10.D 11.B 12.B 13.A 14.D15.A二、填空题安全性控制、完整性控制、并发性控制、数据库恢复数据对象、操作类型授权粒度、授权表中允许的登记项的范围原始数据(或明文)、不可直接识别的格式(或密文)、密文事务、原子性、一致性、隔离性、持久性丢失更新、污读、不可重读封锁、排它型封锁、共享封锁利用数据的冗余登记日志文件、数据转储事务故障、系统故障、介质故障完整性登录账号、用户账号 public 服务器、数据库第6章习题参考答案一、选择题1.B2.C3.C4.A5.C6.B7.C8.B9.D 10.C 11.D 12.B 13.B 14.D二、填空题数据库的结构设计、数据库的行为设计新奥尔良法分析和设计阶段、实现和运行阶段需求分析概念结构设计自顶向下、自底向上属性冲突、命名冲突、结构冲突逻辑结构设计确定物理结构、评价物理结构数据库加载运行和维护物理数据字典需求分析载入第7章习题参考答案一、选择题1.B2.C3.B4.D5.A二、填空题局部变量、全局变量--、/*……*/ DECLARE SQL、流程控制AFTER 触发器、INSTEAD OF 触发器插入表、删除表数据库备份、事务日志备份、差异备份、文件和文件组备份简单还原、完全还原、批日志还原硬盘、磁带、管道第二篇:Access数据库应用教程课后题答案课后选择题答案第1章1.一个教师可讲授多门课程,一门课程可由多个教师讲授,则实体教师和课程间的联系是(D)。

数据库第三章课后习题解答

数据库第三章课后习题解答

3-3 习题33.4 在SQL Server中,创建一个名为students且包含有下列几个属性的表。

SNO char(10);NAME varchar(10);SEX char(1);BDATE datetime;DEPT varchar(10);DORMITORY varchar(10).要求:1.采用两种形式创建表,即用SQL语句和用图形界面的形式来创建。

2.定义必要的约束,包括主键SNO,NAME值不允许为空,且SEX取值为0或1。

【解答】·进入SQL查询分析器建立查询,创建students表的SQL语句如下,操作如图3.17所示。

use mydb /* 假设在mydb库中建表*/create table students(SNO char(10) not NULL primary key,NAME varchar(10) not NULL,SEX char(1) not NULL check(sex='0' or sex='1'),BDATE datetime,DEPT varchar(10),DORMITORY varchar(10))- 1-图3.17 用SQL语句创建students表·进入企业管理器用基本操作创建students表。

用右键单击“mydb”数据库,从弹出的菜单中选择“新建”,再从其下一级菜单中选择“表”。

或者,用右键单击“mydb”数据库下一级的“表”,从弹出的菜单中选择“新建表”。

然后,在弹出的窗体中,把students表所包含的字段逐一输入,每个字段都要指明列名、数据类型、长度和是否允许空值、是否主键等内容,如图3.18所示。

图3.18用基本操作创建students表其中,SEX字段取值为0或1,需要建立约束。

操作是用右键单击SEX字段,从弹出的菜单中选择“CHECK约束”,再从弹出的“属性”窗体中,选择“CHECK约束”卡,在约束表达式框中输入约束表达式,如图3.19所示。

MySQL数据库任务驱动式教程 第3版 项目一 认识数据库

MySQL数据库任务驱动式教程 第3版 项目一 认识数据库

了解数据库的基本应用
4.图书管理系统 图书管理系统主要由4部分组成
项目一 认识数据库
5
信息源
信息处理器
信息用户
信息管理者
软件运行通常模式为C/S或B/S模式,包括图书的采访、编目、流通、查询等功能,有期 刊管理、系统管理、字典管理、Web检索与发布等图书借阅管理子系统。
了解数据库的几个概念
项目一 认识数据库
教师与课程是多对多的关系,要单独对应一个关系模式,把关系模式teachers的主键和关系模 式course的主键一起加入关系模式teach中,作为teach的主键,建立起教师与课程的联系。
学生与课程是多对多的关系,要单独对应一个关系模式,把关系模式students的主键和关系模 式course的主键一起加入关系模式selectcourse中,作为selectcourse的主键,建立起学生与 课程的联系。
departments(单位编号,单位名称,主任,电话) teachers(教师编号,教师姓名,性别,职称,来校时间,单位编号) students(学生编号,学生姓名,性别,出生日期,班级,单位编号) course(课程编号,课程名称,学时,学分,单位编号) teach(教师编号,课程编号) selectcourse(学生编号,课程编号,成绩)
了解数据库的基本应用
2.进销存管理系统
项目一 认识数据库
4
进销存管理系统是有效辅助企业解决业务管理、 分销管理、存货管理、营销计划的执行和监控、 统计信息的收集等业务的管理系统。
该系统要实现的一般功能包括批发销售与零售销 售管理、供货商往来账务管理、客户往来账务管 理、员工管理、销售终端销售管理、财务管理和 库存盘点等。
可以用图来更加直观地描述实体和实体的联系,这样的图叫作实体联系图(EntityRelationship Diagram,E-R图)。一般情况下,用矩形表示实体,用椭圆形表示实体的 属性,用菱形表示实体之间的联系,并用无向直线将属性与实体、实体与实体的联系连 接起来。

(完整word版)数据库系统基础教程第三章答案

(完整word版)数据库系统基础教程第三章答案

Exercise 3.1.1Answers for this exercise may vary because of different interpretations.Some possible FDs:Social Security number → nameArea code → stateStreet address, city, state → zipcodePossible keys:{Social Security number, street address, city, state, area code, phone number}Need street address, city, state to uniquely determine location. A person couldhave multiple addresses. The same is true for phones. These days, a person couldhave a landline and a cellular phoneExercise 3.1.2Answers for this exercise may vary because of different interpretationsSome possible FDs:ID → x-position, y-position, z-positionID → x-velocity, y-velocity, z-velocityx-position, y-position, z-position → IDPossible keys:{ID}{x-position, y-position, z-position}The reason why the positions would be a key is no two molecules can occupy the same point.Exercise 3.1.3aThe superkeys are any subset that contains A1. Thus, there are 2(n-1) such subsets, since each of the n-1 attributes A2 through A n may independently be chosen in or out.Exercise 3.1.3bThe superkeys are any subset that contains A1 or A2. There are 2(n-1) such subsets when considering A1 and the n-1 attributes A2 through A n. There are 2(n-2) such subsets when considering A2 and the n-2 attributes A3 through A n. We do not count A1 in these subsets because they are already counted in the first group of subsets. The total number of subsets is 2(n-1) + 2(n-2).Exercise 3.1.3cThe superkeys are any subset that contains {A1,A2} or {A3,A4}. There are 2(n-2) such subsets when considering {A1,A2} and the n-2 attributes A3 through A n. There are 2(n-2) – 2(n-4) such subsets when considering {A3,A4} and attributes A5 through A n along with the individual attributes A1 and A2. We get the 2(n-4) term because we have to discard the subsets that contain the key {A1,A2} to avoid double counting. The total number of subsets is 2(n-2) +2(n-2) – 2(n-4).Exercise 3.1.3dThe superkeys are any subset that contains {A1,A2} or {A1,A3}. There are 2(n-2) such subsets when considering {A1,A2} and the n-2 attributes A3 through A n. There are 2(n-3) such subsets when considering {A1,A3} and the n-3 attributes A4 through A n We do not count A2 in these subsets because they are already counted in the first group of subsets. The total number of subsets is 2(n-2) + 2(n-3).Exercise 3.2.1aWe could try inference rules to deduce new dependencies until we are satisfied we have them all. A more systematic way is to consider the closures of all 15 nonempty sets of attributes.For the single attributes we have {A}+ = A, {B}+ = B, {C}+ = ACD, and {D}+ = AD. Thus, the only new dependency we get with a single attribute on the left is C→A.Now consider pairs of attributes:{AB}+ = ABCD, so we get new dependency AB→D. {AC}+ = ACD, and AC→D is nontrivial. {AD}+= AD, so nothing new. {BC}+ = ABCD, so we get BC→A, and BC→D. {BD}+ = ABCD, giving us BD→A and BD→C. {CD}+ = ACD, giving CD→A.For the triples of attributes, {ACD}+ = ACD, but the closures of the other sets are each ABCD. Thus, we get new dependencies ABC→D, ABD→C, and BCD→A.Since {ABCD}+ = ABCD, we get no new dependencies.The collection of 11 new dependencies mentioned above are:C→A, AB→D, AC→D, BC→A, BC→D, BD→A, BD→C, CD→A, ABC→D, ABD→C, and BCD→A.Exercise 3.2.1bFrom the analysis of closures above, we find that AB, BC, and BD are keys. All other sets either do not have ABCD as the closure or contain one of these three sets.Exercise 3.2.1cThe superkeys are all those that contain one of those three keys. That is, a superkeythat is not a key must contain B and more than one of A, C, and D. Thus, the (proper) superkeys are ABC, ABD, BCD, and ABCD.Exercise 3.2.2ai) For the single attributes we have {A}+ = ABCD, {B}+ = BCD, {C}+ = C, and {D}+ = D. Thus, the new dependencies are A→C and A→D.Now consider pairs of attributes:{AB}+ = ABCD, {AC}+ = ABCD, {AD}+ = ABCD, {BC}+ = BCD, {BD}+ = BCD, {CD}+ = CD. Thus the new dependencies are AB→C, AB→D, AC→B, AC→D, AD→B, AD→C, BC→D and BD→C.For the triples of attributes, {BCD}+ = BCD, but the closures of the other sets are each ABCD. Thus, we get new dependencies ABC→D, ABD→C, and ACD→B.Since {ABCD}+ = ABCD, we get no new dependencies.The collection of 13 new dependencies mentioned above are:A→C, A→D, AB→C, AB→D, AC→B, AC→D, AD→B, AD→C, BC→D, BD→C, ABC→D, ABD→C and ACD→B.ii) For the single attributes we have {A}+ = A, {B}+ = B, {C}+ = C, and {D}+ = D. Thus, there are no new dependencies.Now consider pairs of attributes:{AB}+ = ABCD, {AC}+ = AC, {AD}+ = ABCD, {BC}+ = ABCD, {BD}+ = BD, {CD}+ = ABCD. Thus the new dependencies are AB→D, AD→C, BC→A and CD→B.For the triples of attributes, all the closures of the sets are each ABCD. Thus, we get new dependencies ABC→D, ABD→C, ACD→B and BCD→A.Since {ABCD}+ = ABCD, we get no new dependencies.The collection of 8 new dependencies mentioned above are:AB→D, AD→C, BC→A, CD→B, ABC→D, ABD→C, ACD→B and BCD→A.iii) For the single attributes we have {A}+ = ABCD, {B}+ = ABCD, {C}+ = ABCD, and {D}+ = ABCD. Thus, the new dependencies are A→C, A→D, B→D, B→A, C→A, C→B, D→B and D→C.Since all the single attributes’ closures are ABCD, any superset of the singleattributes will also lead to a closure of ABCD. Knowing this, we can enumerate the restof the new dependencies.The collection of 24 new dependencies mentioned above are:A→C, A→D, B→D, B→A, C→A, C→B, D→B, D→C, AB→C, AB→D, AC→B, AC→D, AD→B, AD→C, BC→A, BC→D, BD→A, BD→C, CD→A, CD→B, ABC→D, ABD→C, ACD→B and BCD→A.Exercise 3.2.2bi) From the analysis of closures in 3.2.2a(i), we find that the only key is A. All other sets either do not have ABCD as the closure or contain A.ii) From the analysis of closures 3.2.2a(ii), we find that AB, AD, BC, and CD are keys.All other sets either do not have ABCD as the closure or contain one of these four sets.iii) From the analysis of closures 3.2.2a(iii), we find that A, B, C and D are keys. All other sets either do not have ABCD as the closure or contain one of these four sets.Exercise 3.2.2ci) The superkeys are all those sets that contain one of the keys in 3.2.2b(i). The superkeys are AB, AC, AD, ABC, ABD, ACD, BCD and ABCD.ii) The superkeys are all those sets that contain one of the keys in 3.2.2b(ii). The superkeys are ABC, ABD, ACD, BCD and ABCD.iii) The superkeys are all those sets that contain one of the keys in 3.2.2b(iii). The superkeys are AB, AC, AD, BC, BD, CD, ABC, ABD, ACD, BCD and ABCD.Exercise 3.2.3aSince A1A2…A n C contains A1A2…A n, then the closure of A1A2…A n C contains B. Thus it follows that A1A2…A n C→B.Exercise 3.2.3bFrom 3.2.3a, we know that A1A2…A n C→B. Using the concept of trivial dependencies, we can show that A1A2…A n C→C. Thus A1A2…A n C→BC.Exercise 3.2.3cFrom A1A2…A n E1E2…E j, we know that the closure contains B1B2…B m because of the FD A1A2…A n→B1B2…B m. The B1B2…B m and the E1E2…E j combine to form the C1C2…C k. Thus the closure ofA1A2…A n E1E2…E j contains D as well. Thus, A1A2…A n E1E2…E j→D.Exercise 3.2.3dFrom A1A2…A n C1C2…C k, we know that the closure contains B1B2…B m because of the FD A1A2…A n→B1B2…B m. The C1C2…C k also tell us that the closure of A1A2…A n C1C2…C k contains D1D2…D j. Thus, A1A2…A n C1C2…C k→B1B2…B k D1D2…D j.Exercise 3.2.4aIf attribute A represented Social Security Number and B represented a person’s name,then we would assume A→B but B→A would not be valid because there may be many peoplewith the same name and different Social Security Numbers.Exercise 3.2.4bLet attribute A represent Social Security Number, B represent gender and C represent name. Surely Social Security Number and gender can uniquely identify a person’s name (i.e.AB→C). A Social Security Number can also uniquely identify a person’s name (i.e. A→C). However, gender does not uniquely determine a name (i.e. B→C is not valid).Exercise 3.2.4cLet attribute A represent latitude and B represent longitude. Together, both attributes can uniquely determine C, a point on the world map (i.e. AB→C). However, neither A nor B can uniquely identify a point (i.e. A→C and B→C are not valid).Exercise 3.2.5Given a relation with attributes A1A2…A n, we are told that there are no functional dependencies of the form B1B2…B n-1→C where B1B2…B n-1 is n-1 of the attributes from A1A2…A n and C is the remaining attribute from A1A2…A n. In this case, the set B1B2…B n-1 and any subset do not functionally determine C. Thus the only functional dependencies that we can make are ones where C is on both the left and right hand sides. All of these functional dependencies would be trivial and thus the relation has no nontrivial FD’s.Exercise 3.2.6Let’s prove this by using the contrapositive. We wish to show that if X+ is not a subset of Y+, then it must be that X is not a subset of Y.If X+ is not a subset of Y+, there must be attributes A1A2…A n in X+ that are not in Y+. If any of these attributes were originally in X, then we are done because Y does not contain any of the A1A2…A n. However, if the A1A2…A n were added by the closure, then we must examine the case further. Assume that there was some FD C1C2…C m→A1A2…A j where A1A2…A j is some subset of A1A2…A n. It must be then that C1C2…C m or some subset of C1C2…C m is in X. However, the attributes C1C2…C m cannot be in Y because we assumed that attributes A1A2…A n are only in X+ and are not in Y+. Thus, X is not a subset of Y.By proving the contrapositive, we have also proved if X ⊆ Y, then X+⊆ Y+.Exercise 3.2.7The algorithm to find X+ is outlined on pg. 76. Using that algorithm, we can prove that (X+)+ = X+. We will do this by using a proof by contradiction.Suppose that (X+)+≠ X+. Then for (X+)+, it must be that some FD allowed additional attributes to be added to the original set X+. For example, X+→ A where A is some attribute not in X+. However, if this were the case, then X+ would not be the closure of X. The closure of X would have to include A as well. This contradicts the fact that we weregiven the closure of X, X+. Therefore, it must be that (X+)+ = X+ or else X+ is not the closure of X.Exercise 3.2.8aIf all sets of attributes are closed, then there cannot be any nontrivial functional dependencies. Suppose A1A2...A n→B is a nontrivial dependency. Then {A1A2...A n}+ contains B and thus A1A2...A n is not closed.Exercise 3.2.8bIf the only closed sets are ø and {A,B,C,D}, then the following FDs hold:A→B A→C A→DB→A B→C B→DC→A C→B C→DD→A D→B D→CAB→C AB→DAC→B AC→DAD→B AD→CBC→A BC→DBD→A BD→CCD→A CD→BABC→DABD→CACD→BBCD→AExercise 3.2.8cIf the only closed sets are ø, {A,B} and {A,B,C,D}, then the following FDs hold:A→BB→AC→A C→B C→DD→A D→B D→CAC→B AC→DAD→B AD→CBC→A BC→DBD→A BD→CCD→A CD→BABC→DABD→CACD→BBCD→AExercise 3.2.9We can think of this problem as a situation where the attributes A,B,C represent cities and the functional dependencies represent one way paths between the cities. The minimal bases are the minimal number of pathways that are needed to connect the cities. We do not want to create another roadway if the two cities are already connected.The systematic way to do this would be to check all possible sets of the pathways. However, we can simplify the situation by noting that it takes more than two pathways to visit the two other cities and come back. Also, if we find a set of pathways that is minimal, adding additional pathways will not create another minimal set.The two sets of minimal bases that were given in example 3.11 are:{A→B, B→C, C→A}{A→B, B→A, B→C, C→B}The additional sets of minimal bases are:{C→B, B→A, A→C}{A→B, A→C, B→A, C→A}{A→C, B→C, C→A, C→B}Exercise 3.2.10aWe need to compute the closures of all subsets of {ABC}, although there is no need to think about the empty set or the set of all three attributes. Here are the calculations for the remaining six sets:{A}+=A{B}+=B{C}+=ACE{AB}+=ABCDE{AC}+=ACE{BC}+=ABCDEWe ignore D and E, so a basis for the resulting functional dependencies for ABC is: C→A and AB→C. Note that BC->A is true, but follows logically from C->A, and therefore may be omitted from our list.Exercise 3.2.10bWe need to compute the closures of all subsets of {ABC}, although there is no need to think about the empty set or the set of all three attributes. Here are the calculations for the remaining six sets:{A}+=AD{B}+=B{C}+=C{AB}+=ABDE{AC}+=ABCDE{BC}+=BCWe ignore D and E, so a basis for the resulting functional dependencies for ABC is: AC→B.Exercise 3.2.10cWe need to compute the closures of all subsets of {ABC}, although there is no need tothink about the empty set or the set of all three attributes. Here are the calculationsfor the remaining six sets:{A}+=A{B}+=B{C}+=C{AB}+=ABD{AC}+=ABCDE{BC}+=ABCDEWe ignore D and E, so a basis for the resulting functional dependencies for ABC is: AC→B and BC→A.Exercise 3.2.10dWe need to compute the closures of all subsets of {ABC}, although there is no need tothink about the empty set or the set of all three attributes. Here are the calculationsfor the remaining six sets:{A}+=ABCDE{B}+=ABCDE{C}+=ABCDE{AB}+=ABCDE{AC}+=ABCDE{BC}+=ABCDEWe ignore D and E, so a basis for the resulting functional dependencies for ABC is: A→B, B→C and C→A.Exercise 3.2.11For step one of Algorithm 3.7, suppose we have the FD ABC→DE. We want to use Armstrong’s Axioms to show that ABC→D and ABC→E follow. Surely the functional dependencies DE→D and DE→E hold because they are trivial and follow the reflexivity property. Using the transitivity rule, we can derive the FD ABC→D from the FDs ABC→DE and DE→D. Likewise, we can do the same for ABC→DE and DE→E and derive the FD ABC→E.For steps two through four of Algorithm 3.7, suppose we have the initial set ofattributes of the closure as ABC. Suppose also that we have FDs C→D and D→E. Accordingto Algorithm 3.7, the closure should become ABCDE. Taking the FD C→D and augmenting both sides with attributes AB we get the FD ABC→ABD. We can use the splitting method in stepone to get the FD ABC→D. Since D is not in the closure, we can add attribute D. Taking the FD D→E and augmenting both sides with attributes ABC we get the FD ABCD→ABCDE.Using again the splitting method in step one we get the FD ABCD→E. Since E is not in the closure, we can add attribute E.Given a set of FDs, we can prove that a FD F follows by taking the closure of the left side of FD F. The steps to compute the closure in Algorithm 3.7 can be mimicked by Armstrong’s axioms and thus we can prove F from the given set of FDs using Armstrong’s axioms.Exercise 3.3.1aIn the solution to Exercise 3.2.1 we found that there are 14 nontrivial dependencies, including the three given ones and eleven derived dependencies. They are: C→A, C→D,D→A, AB→D, AB→ C, AC→D, BC→A, BC→D, BD→A, BD→C, CD→A, ABC→D, ABD→C, and BCD→A.We also learned that the three keys were AB, BC, and BD. Thus, any dependency above that does not have one of these pairs on the left is a BCNF violation. These are: C→A, C→D,D→A, AC→D, and CD→A.One choice is to decompose using the violation C→D. Using the above FDs, we get ACD and BC as decomposed relations. BC is surely in BCNF, since any two-attribute relation is. Using Algorithm 3.12 to discover the projection of FDs on relation ACD, we discover that ACD is not in BCNF since C is its only key. However, D→A is a dependency that holds in ABCD and therefore holds in ACD. We must further decompose ACD into AD and CD. Thus, the three relations of the decomposition are BC, AD, and CD.Exercise 3.3.1bBy computing the closures of all 15 nonempty subsets of ABCD, we can find all thenontrivial FDs. They are B→C, B→D, AB→C, AB→D, BC→D, BD→C, ABC→D and ABD→C. From the closures we can also deduce that the only key is AB. Thus, any dependency above that does not contain AB on the left is a BCNF violation. These are: B→C, B→D, BC→D andBD→C.One choice is to decompose using the violation B→C. Using the above FDs, we get BCD and AB as decomposed relations. AB is surely in BCNF, since any two-attribute relation is. Using Algorithm 3.12 to discover the projection of FDs on relation BCD, we discover that BCD is in BCNF since B is its only key and the projected FDs all have B on the left side. Thus the two relations of the decomposition are AB and BCD.Exercise 3.3.1cIn the solution to Exercise 3.2.2(ii), we found that there are 12 nontrivial dependencies, including the four given ones and the eight derived ones. They are AB→C, BC→D, CD→A, AD→B, AB→D, AD→C, BC→A, CD→B, ABC→D, ABD→C, ACD→B and BCD→A.We also found out that the keys are AB, AD, BC, and CD. Thus, any dependency above that does not have one of these pairs on the left is a BCNF violation. However, all of the FDs contain a key on the left so there are no BCNF violations.No decomposition is necessary since all the FDs do not violate BCNF.Exercise 3.3.1dIn the solution to Exercise 3.2.2(iii), we found that there are 28 nontrivial dependencies, including the four given ones and the 24 derived ones. They are A→B, B→C, C→D, D→A, A→C, A→D, B→D, B→A, C→A, C→B, D→B, D→C, AB→C, AB→D, AC→B, AC→D,AD→B, AD→C, BC→A, BC→D, BD→A, BD→C, CD→A, CD→B, ABC→D, ABD→C, ACD→B and BCD→A.We also found out that the keys are A,B,C,D. Thus, any dependency above that does nothave one of these attributes on the left is a BCNF violation. However, all of the FDs contain a key on the left so there are no BCNF violations.No decomposition is necessary since all the FDs do not violate BCNF.Exercise 3.3.1eBy computing the closures of all 31 nonempty subsets of ABCDE, we can find all the nontrivial FDs. They are AB→C, DE→C, B→D, AB→D, BC→D, BE→C, BE→D, ABC→D, ABD→C, ABE→C, ABE→D, ADE→C, BCE→D, BDE→C, ABCE→D, and ABDE→C. From the closures we canalso deduce that the only key is ABE. Thus, any dependency above that does not contain ABE on the left is a BCNF violation. These are: AB→C, DE→C, B→D, AB→D, BC→D, BE→C, BE→D, ABC→D, ABD→C, ADE→C, BCE→D and BDE→C.One choice is to decompose using the violation AB→C. Using the above FDs, we get ABCDand ABE as decomposed relations. Using Algorithm 3.12 to discover the projection of FDs on relation ABCD, we discover that ABCD is not in BCNF since AB is its only key and the FD B→D follows for ABCD. Using violation B→D to further decompose, we get BD and ABC as decomposed relations. BD is in BCNF because it is a two-attribute relation. Using Algorithm 3.12 again, we discover that ABC is in BCNF since AB is the only key and AB→Cis the only nontrivial FD. Going back to relation ABE, following Algorithm 3.12 tells us that ABE is in BCNF because there are no keys and no nontrivial FDs. Thus the three relations of the decomposition are ABC, BD and ABE.Exercise 3.3.1fBy computing the closures of all 31 nonempty subsets of ABCDE, we can find all the nontrivial FDs. They are: C→B, C→D, C→E, D→B, D→E, AB→C, AB→D, AB→E, AC→B, AC→D, AC→E, AD→B, AD→C, AD→E, BC→D, BC→E, BD→E, CD→B, CD→E, CE→B, CE→D, DE→B,ABC→D, ABC→E, ABD→C, ABD→E, ABE→C, ABE→D, ACD→B, ACD→E, ACE→B, ACE→D, ADE→B, ADE→C, BCD→E, BCE→D, CDE→B, ABCD→E, ABCE→D, ABDE→C and ACDE→B. From the closures we can also deduce that the keys are AB, AC and AD. Thus, any dependency above that does not contain one of the above pairs on the left is a BCNF violation. These are: C→B, C→D,C →E,D →B, D →E, BC →D, BC →E, BD →E, CD →B, CD →E, CE →B, CE →D, DE →B, BCD →E, BCE →D and CDE →B.One choice is to decompose using the violation D →B. Using the above FDs, we get BDE and ABC as decomposed relations. Using Algorithm 3.12 to discover the projection of FDs on relation BDE, we discover that BDE is in BCNF since D, BD, DE are the only keys and all the projected FDs contain D, BD, or DE in the left side. Going back to relation ABC,following Algorithm 3.12 tells us that ABC is not in BCNF because since AB and AC are its only keys and the FD C →B follows for ABC. Using violation C →B to further decompose, we get BC and AC as decomposed relations. Both BC and AC are in BCNF because they are two-attribute relations. Thus the three relations of the decomposition are BDE, BC and AC.Exercise 3.3.2Yes, we will get the same result. Both A →B and A →BC have A on the left side and part ofthe process of decomposition involves finding {A}+to form one decomposed relation and Aplus the rest of the attributes not in {A}+as the second relation. Both cases yield the same decomposed relations.Exercise 3.3.3Yes, we will still get the same result. Both A →B and A →BC have A on the left side andpart of the process of decomposition involves finding {A}+to form one decomposedrelation and A plus the rest of the attributes not in {A}+as the second relation. Both cases yield the same decomposed relations.Exercise 3.3.4This is taken from Example 3.21 pg. 95.Suppose that an instance of relation R only contains two tuples.The projections of R onto the relations with schemas {A,B} and {B,C} are:If we do a natural join on the two projections, we will get:The result of the natural join is not equal to the original relation R.Exercise 3.4.1aThis is the initial tableau:→A.Since there is not an unsubscripted row, the decomposition for R is not lossless for this set of FDs.We can use the final tableau as an instance of R as an example for why the join is not lossless. The projected relations are:The joined relation is:The joined relation has three more tuples than the original tableau.Exercise 3.4.1bThis is the initial tableau:This is the final tableau after applying FDs AC→E and BC→DSince there is an unsubscripted row, the decomposition for R is lossless for this set of FDs.Exercise 3.4.1cThis is the initial tableau:This is the final tableau after applying FDs A→D, D→E and B→D.Since there is an unsubscripted row, the decomposition for R is lossless for this set of FDs.Exercise 3.4.1dThis is the initial tableau:This is the final tableau after applying FDs A→D, CD→E and E→DSince there is an unsubscripted row, the decomposition for R is lossless for this set of FDs.Exercise 3.4.2When we decompose a relation into BCNF, we will project the FDs onto the decomposed relations to get new sets of FDs. These dependencies are preserved if the union of these new sets is equivalent to the original set of FDs.For the FDs of 3.4.1a, the dependencies are not preserved. The union of the new sets of FDs is CE→A. However, the FD B→E is not in the union and cannot be derived. Thus the two sets of FDs are not equivalent.For the FDs of 3.4.1b, the dependencies are preserved. The union of the new sets of FDs is AC→E and BC→D. This is precisely the same as the original set of FDs and thus the two sets of FDs are equivalent.For the FDs of 3.4.1c, the dependencies are not preserved. The union of the new sets of FDs is B→D and A→E. The FDs A→D and D→E are not in the union and cannot be derived. Thus the two sets of FDs are not equivalent.For the FDs of 3.4.1d, the dependencies are not preserved. The union of the new sets of FDs is AC→E. However, the FDs A→D, CD→E and E→D are not in the union and cannot be derived. Thus the two sets of FDs are not equivalent.Exercise 3.5.1aIn the solution to Exercise 3.3.1a we found that there are 14 nontrivial dependencies. They are: C→A, C→D, D→A, AB→D, AB→ C, AC→D, BC→A, BC→D, BD→A, BD→C, CD→A,ABC→D, ABD→C, and BCD→A.We also learned that the three keys were AB, BC, and BD. Since all the attributes on the right sides of the FDs are prime, there are no 3NF violations.Since there are no 3NF violations, it is not necessary to decompose the relation.Exercise 3.5.1bIn the solution to Exercise 3.3.1b we found that there are 8 nontrivial dependencies. They are B→C, B→D, AB→C, AB→D, BC→D, BD→C, ABC→D and ABD→C.We also found out that the only key is AB. FDs where the left side is not a superkey or the attributes on the right are not part of some key are 3NF violations. The 3NF violations are B→C, B→D, BC→D and BD→C.Using algorithm 3.26, we can decompose into relations using the minimal basis B→C andB→D. The resulting decomposed relations would be BC and BD. However, none of these two sets of attributes is a superkey. Thus we add relation AB to the result. The final set of decomposed relations is BC, BD and AB.Exercise 3.5.1cIn the solution to Exercise 3.3.1c we found that there are 12 nontrivial dependencies. They are AB→C, BC→D, CD→A, AD→B, AB→D, AD→C, BC→A, CD→B, ABC→D, ABD→C, ACD→B and BCD→A.We also found out that the keys are AB, AD, BC, and CD. Since all the attributes on the right sides of the FDs are prime, there are no 3NF violations.Since there are no 3NF violations, it is not necessary to decompose the relation.Exercise 3.5.1dIn the solution to Exercise 3.3.1d we found that there are 28 nontrivial dependencies. They are A→B, B→C, C→D, D→A, A→C, A→D, B→D, B→A, C→A, C→B, D→B, D→C, AB→C,AB→D, AC→B, AC→D, AD→B, AD→C, BC→A, BC→D, BD→A, BD→C, CD→A, CD→B, ABC→D,ABD→C, ACD→B and BCD→A.We also found out that the keys are A,B,C,D. Since all the attributes on the right sidesof the FDs are prime, there are no 3NF violations.Since there are no 3NF violations, it is not necessary to decompose the relation.Exercise 3.5.1eIn the solution to Exercise 3.3.1e we found that there are 16 nontrivial dependencies. They are AB→C, DE→C, B→D, AB→D, BC→D, BE→C, BE→D, ABC→D, ABD→C, ABE→C, ABE→D, ADE→C, BCE→D, BDE→C, ABCE→D, and ABDE→C.We also found out that the only key is ABE. FDs where the left side is not a superkey or the attributes on the right are not part of some key are 3NF violations. The 3NFviolations are AB→C, DE→C, B→D, AB→D, BC→D, BE→C, BE→D, ABC→D, ABD→C, ADE→C, BCE→D and BDE→C.Using algorithm 3.26, we can decompose into relations using the minimal basis AB→C,DE→C and B→D. The resulting decomposed relations would be ABC, CDE and BD. However,none of these three sets of attributes is a superkey. Thus we add relation ABE to the result. The final set of decomposed relations is ABC, CDE, BD and ABE.Exercise 3.5.1fIn the solution to Exercise 3.3.1f we found that there are 41 nontrivial dependencies. They are: C→B, C→D, C→E, D→B, D→E, AB→C, AB→D, AB→E, AC→B, AC→D, AC→E, AD→B, AD→C, AD→E, BC→D, BC→E, BD→E, CD→B, CD→E, CE→B, CE→D, DE→B, ABC→D, ABC→E,ABD→C, ABD→E, ABE→C, ABE→D, ACD→B, ACD→E, ACE→B, ACE→D, ADE→B, ADE→C, BCD→E, BCE→D, CDE→B, ABCD→E, ABCE→D, ABDE→C and ACDE→B.We also found out that the keys are AB, AC and AD. FDs where the left side is not a superkey or the attributes on the right are not part of some key are 3NF violations. The3NF violations are C→E, D→E, BC→E, BD→E, CD→E and BCD→E.Using algorithm 3.26, we can decompose into relations using the minimal basis AB→C, C→D, D→B and D→E. The resulting decomposed relations would be ABC, CD, BD and DE. Since relation ABC contains a key, we can stop with the decomposition. The final set of decomposed relations is ABC, CD, BD and DE.Exercise 3.5.2aThe usual procedure to find the keys would be to take the closure of all 63 nonempty subsets. However, if we notice that none of the right sides of the FDs contains。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

当键只包括一个单独的属性A时,称A(而不是{A})是键。
3.1 Functional Dependencies
2. Keys of Relations
Example: Student(ID, Name, Sex, Birth);
Now, we must argue that all proper subset of {ID, Name, Sex, Birth} functionally determines all other attributes. 下面将讨论的是{ID, Name, Sex, Birth} 的任一真子集都是否函数决定其他的属性。 {ID}; {Name}; {Sex}; {Birth}; {ID, Name}; {ID, Sex}; {ID, Birth}; {Name, Sex}; {Name, Birth}; {Sex, Birth} ; {ID, Name, Sex}; {ID, Name, Birth}; {ID, Sex, Birth}; {Name, Sex, Birth}; {ID, Name, Sex, Birth}
Relational Schema: SCJ(SID, SName, CID, CName, Score) SID → SName CID → CName (SID, CID) → Score
1002
1003 1003 1004
Rose
Flora Flora James
K01
K01 K02 K02
CE
3.1 Functional Dependencies
2. Keys of Relations Sometimes a relation has more than one key. If so, it is common to designate one of the keys as the primary key. In commercial database systems, the choice of primary key can influence some implementation issues such as how the relation is stored on disk. However, the theory of FD’s gives to special role to “primary key”.
3.1 Functional Dependencies
1. Definition of Functional Dependency If we can be sure every instance of a relation R will be one in which a given FD is true, then we say that R satisfies the FD. It is important to remember that when we say that R satisfies an FD f, we are asserting a constraint on R, not just saying something about one particular instance of R. It is common for the right side of an FD to be a single attribute.
3.1 Functional Dependencies
1. Definition of Functional Dependency 函数依赖的定义
A functional dependency(FD) on a relation R is a statement of the form “If two tuples of R agree on all of the attributes A1,A2,…,An (i.e., the tuples has the same values in their respective components for each of these attributes), then they must also agree on all of another list of attributes B1,B2,…,Bm. We write this FD formally as A1,A2,…,An → B1,B2,…,Bm and say that “A1,A2,…,An functionally determine B1,B2,…,Bm” 关系R上的函数依赖是指如果R的两个元组在属性A1,A2,…,An上一致(即它们对 应于这些属性的分量值都相等),那么它们必定在其他属性 B1,B2,…,Bm上也一致。 该函数依赖形式地记为 A1,A2,…,An → B1,B2,…,Bm ,并称为 A1,A2,…,An函数决定 B1,B2,…,Bm。
FD:
Social Security number → {Name, Area code, State, City, Street Adrress, Zipcode, Phone}
Area code State Street address, City, State zipcode Key: Social Security number {Street address, City, Area code, Phone, Name}
3.1 Functional Dependencies
2. Keys of Relations 关系的键
(2) No proper subset of {A1,A2,…,An} functionally determines all other attributes of R; i.e., a key must be minimal. 在{A1,A2,…,An} 的真子集中,没有一个能函数决定 R 的所有其他属性。也就是 说,键必须是最小的。 When a key consists of (rather than {A}) is a key. a single attribute A, we often say that A
有时一个关系可能会有多个键。如果是这样的话,通常就要指定其中一个为主键。 在商业数据库系统中,对主键的选择会影响某些实现问题,例如怎样在磁盘中存储关 系。然而,函数依赖理论并未给主键以特殊的角色。
3.1 Functional Dependencies
3. Super key 超键 A set of attributes that contains a key is called a super key, short for “super set of a key”. Thus, every key is a super key. However, some super keys are not minimal key. Note that every super key satisfies the first condition of a key: it functionally determines all other attributes of the relation. However, a super key need not satisfy the second condition:
如果确定关系R的每个实例都能使一个给定的FD为真,那么称R满足函数依赖f。 这是在R上声明了一个约束,而不是仅仅针对R的一个特殊实例。通常,FD的右边可 能是单个属性。
3.1 Functional Dependencies
Example:
SID 1001 1001 1001 1002 SName Jacky Jacky Jacky Rose CID T01 K01 T02 T01 CName OS CE DS OS Score 78 85 87 72
minimality.
一个包含键的属性集就叫做超键,它是键的超集的简写。因此,每个键都是超键。 然而,某些超键不是键。注意,每个超键都满足键的第一个条件:它函数决定了关系 中所有其他属性。但超键不需要满足第二个条件:最小化。
3.1 Functional Dependencies
4. Exercise (1)考虑一个关于美国公民的关系,这个关系的属性有:姓名、社会保险号、街道 地址、城市、州、邮编、地区代码和电话号码(7位数字)。这个关系有哪些FD?关 系的键是什么?(假设一个地区只能用于一个州,一个邮编不能跨越两个地区代码, 两个人不能有相同的社会保险号,但可以有相同的地址和电话号码)
There is a design theory for relations that lets us examine a design carefully and make improvements based on a few simple principles. The theory begins by having us state the constraints that apply to the relation. The most common constraint is the “functional dependency”, a statement of a type that generalizes the idea of a key for a relation, which we introduced in Section 2.5.3. Later in this chapter, we shall see how this theory gives up simple tools to improve our designs by the process of “decomposition” of relations : the replacement of one relation by several, whose sets of attributes together include all the attributes of the original. 关系的设计理论使人们可以根据少数简单原则来认真检验一个设计并做出改进。这一 理论首先能够规定作用在关系上的约束。最常见的约束是“函数依赖”,它泛化了关系中 “键”的概念。本章随后介绍如何使用关系设计理论给予的一些简单工具,通过关系的分 解过程来改进设计,即用若干关系替代原关系,这些关系的属性集合包含了原关系的所有 属性。
相关文档
最新文档