数据库范式练习题

合集下载

数据库应用试题及答案

数据库应用试题及答案

数据库应用试题及答案一、选择题1. 在关系数据库中,用于查询数据的SQL语句是:A. CREATEB. INSERTC. SELECTD. UPDATE答案:C2. 以下哪个不是数据库的范式?A. 第一范式(1NF)B. 第二范式(2NF)C. 第三范式(3NF)D. 第四范式(4NF)答案:D3. 以下哪个是数据库事务的四大特性之一?A. 可扩展性B. 一致性C. 可用性D. 持久性答案:B4. 在SQL中,用于删除表中数据的语句是:A. DROPB. DELETEC. REMOVED. ERASE答案:B5. 数据库管理系统(DBMS)的主要功能不包括:A. 数据存储B. 数据保护C. 数据加密D. 数据查询答案:C二、简答题1. 简述数据库的三级模式结构。

答案:数据库的三级模式结构包括外模式、概念模式和内模式。

外模式是用户视图,是用户与数据库交互的接口;概念模式是全局逻辑视图,描述了数据库的总体逻辑结构;内模式是存储视图,描述了数据的物理存储方式。

2. 什么是数据库的完整性约束?请列举至少三种。

答案:数据库的完整性约束是确保数据库中数据准确性和一致性的规则。

常见的完整性约束包括:- 实体完整性:确保表中的每一行都有一个唯一的标识符。

- 参照完整性:确保表之间的关联关系正确无误。

- 用户定义的完整性:根据特定业务规则定义的约束。

三、应用题1. 假设有一个学生信息表(Students),包含字段:学生ID (StudentID),姓名(Name),年龄(Age),专业(Major)。

编写一个SQL查询,列出所有年龄大于20岁的学生信息。

答案:```sqlSELECT * FROM Students WHERE Age > 20;```2. 编写一个SQL语句,向学生信息表中插入一条新记录,学生ID为1001,姓名为“张三”,年龄为22,专业为“计算机科学”。

答案:```sqlINSERT INTO Students (StudentID, Name, Age, Major) VALUES (1001, '张三', 22, '计算机科学');```3. 如果需要删除学生信息表中所有计算机科学专业的学生记录,请编写相应的SQL语句。

数据库范式习题答案

数据库范式习题答案

Normalization Questions and AnswersDatabase Systems,CSCI4380-01Sibel AdalıOctober28,2002Question1Suppose you are given a relation R=(A,B,C,D,E)with the following functional dependencies:{CE→D,D→B,C→A}.a.Find all candidate keys.b.Identify the best normal form that R satisfies(1NF,2NF,3NF,or BCNF).c.If the relation is not in BCNF,decompose it until it becomes BCNF.At each step,identify a new relation,decompose and re-compute the keys and the normal forms they satisfy.Answer.a.The only key is{C,E}b.The relation is in1NFc.Decompose into R1=(A,C)and R2=(B,C,D,E).R1is in BCNF,R2is in2NF.Decompose R2 into,R21=(C,D,E)and R22=(B,D).Both relations are in BCNF.Question2Suppose you are given a relation R=(A,B,C,D,E)with the following functional de-pendencies:{BC→ADE,D→B}.a.Find all candidate keys.b.Identify the best normal form that R satisfies(1NF,2NF,3NF,or BCNF).c.If the relation is not in BCNF,decompose it until it becomes BCNF.At each step,identify a new relation,decompose and re-compute the keys and the normal forms they satisfy.Answer.a.The keys are{B,C}and{C,D}b.The relation is in3NFc.It cannot be put into BCNF,even if I remove D and put into a relation of the form(B,C,D)(I need C for the functional dependency),the resulting relation would not be in BCNF.Question3Suppose you are given a relation R=(A,B,C,D,E)with the following functional de-pendencies:BD→E,A→C.a.Show that the decomposition into R1=(A,B,C)and R2=(D,E)is lossy.You can show using any method.My suggestion is to show how spurious tuples result from this decomposition with respect to the table below:A B C D E12345183441b.Find a single dependency from a single attribute X to another attribute Y such that when you add the dependency X→Y to the above dependencies,the decomposition in part a is no longer lossy.Answer.a.If we were to decompose the relations into:A B C 123 183D E 45 44and then join the two(in this case with a cartesian product),we would get:A B C D E12345183451234418344Tuples2and3are not in the original relation.Hence,this decomposition is lossy.b.This decomposition cannot be made lossless.The problem is there is no longer a way to make sure BD→E holds across two relations since they do not share any attributes.However,a lossy decomposition of the form(A,B,C),(C,D,E)can be made lossless by adding an FD B→C. Question4You are given the following set of functional dependencies for a relation R(A,B,C,D,E,F), F={AB→C,DC→AE,E→F}.a.What are the keys of this relation?b.Is this relation in BCNF?If not,explain why by showing one violation.c.Is the decomposition(A,B,C,D)(B,C,D,E,F)a dependency preserving decomposition?If not, explain briefly.Answer.a.What are the keys of this relation?{A,B,D}and{B,C,D}.b.Is this relation in BCNF?If not,explain why by showing one violation.No,all functional dependencies are actually violating this.No dependency contains a superkey on its left side.c.Is the decomposition(A,B,C,D)(B,C,D,E,F)a dependency preserving decomposition?If not, explain briefly.Yes,AB→C and DC→A are preserved in thefirst relation.DC→E and E→F are preserved in the second relation.Question5You are given the below functional dependencies for relation R(A,B,C,D,E),F= {AB→C,AB→D,D→A,BC→D,BC→E}.a.Is this relation is in BCNF?If not,show all dependencies that violate it.b.Is this relation in3NF?If not,show all dependencies that violate it.2c.Is the following dependency implied by the above set of dependencies?If so,show how using the Amstrong’s Axioms given in the book(p.362-363):ABC→AEAnswer.Keys for the relation:{A,B},{B,D},{B,C}.a.Not in BCNF since D→A does have a superkey on the left hand side.b.In3NF since in D→A,A is part of a key.c.BC→E(given)ABC→AE by the augmentation rule.Question6You are given the table below for a relation R(A,B,C,D,E).You do not know the functional dependencies for this relation.This question is independent of Question2above.A B C D E’a’1221’s1’’a’’e’2364’e2’’b’’a’1991’b5’’c’’b’2132’z8’’d’Suppose this relation is decomposed into the following two tables:R1(A,B,C,D)and R2(A,C,E). Is this decomposition lossless?Explain your reasoning.Answer.R1A B C D ’a’1221’s1’’e’2364’e2’’a’1991’b5’’b’2132’z8’R2A C E’a’1’a’’e’4’b’’a’1’c’’b’2’d’R1 R2A B C D E’a’1221’s1’’a’’e’2364’e2’’b’’a’1991’b5’’c’’b’2132’z8’’d’’a’1221’s1’’a’’a’1991’b5’’c’Since the last two rows are not in the original relation,then this decomposition is lossy.Question7You are given the below set of functional dependencies for a relation R(A,B,C,D,E,F,G), F={AD→BF,CD→EGC,BD→F,E→D,F→C,D→F}.a.Find the minimal cover for the above set of functional dependencies using the algorithm described in class.Give sufficient detail to show your reasoning,but be succinct.You do not have to list all the cases you test/consider for the algorithm.Show all steps where you make changes to the above set in detail.ing the functional dependencies that you computed in step a,find the keys for this relation. Is it in BCNF?Explain your reasoning.c.Suppose we decompose the above relation into the following two relations:R1(A,B,C,D,E)R2(A,D,F,G)Use the functional dependencies in the minimal cover.For each relation,write down the functional dependencies that fall within that relation(you can decompose a dependency of the form AD→BF into two i.e.AD→B and AD→F when computing this).3Using these functional dependencies,determine if this decomposition is lossless and/or dependency preserving.Explain your reasoning.Answers.a.Step1.{AD→B,AD→F,CD→E,CD→G,CD→C,BD→F,E→D,F→C,D→F}Step2.removeCD→C,AD→F,and BD→F.{AD→B,CD→E,CD→G,F→C,D→F,E→D}Step3.remove D from CD→E and CD→G{AD→B,D→E,D→G,F→C,D→F,E→D}Finally recombine{AD→B,D→EGF,F→C,E→D}.b.Keys:{A,D},{A,E}.Not in BCNF since the last three functional dependencies do not have a superkey on the left hand side.c.R1(A,B,C,D,E)Dependencies:AD→B,D→E,E→D R2(A,D,F,G)Dependencies:D→GF.Not functional dependency preserving,the dependency F→C is not preserved.head(R1)∩head(R2)={A,D}R1:AD→ABCDE is not true since C is not implied by A,DR2:AD→ADF G is true since this is implied by D→GF as follows:AD→AD inclusion rule,since D→GF,use set accumulation rule,AD→ADGF.Hence,thisis a lossless decomposition.Question8You are given the following set F of functional dependencies for a relation R(A,B,C,D,E,F): F={ABC→D,ABD→E,CD→F,CDF→B,BF→D}.a.Find all keys of R based on these functional dependencies.b.Is this relation in Boyce-Codd Normal Form?Is it3NF?Explain your answers.c.Can the set F be simplified(by removing functional dependencies or by removing attributes from the left hand side of functional dependencies)without changing the closure of F(i.e.F+)? Hint.Consider the steps of the minimal cover algorithm.Do any of them apply to this functional dependency?Answer.a.Keys:{A,B,C}and{A,C,D}b.It is not in BCNF.Counterexample ABD→E and ABD is not a superkey.It is not in3NF.Counterexample ABD→E,and ABD is not a superkey and E is not prime attribute(part of a key).c.Let F’be obtained by replacing CDF→B with CD→B.According to F and F’,CD+={C,D,B,F}.Hence,we can remove F from this functional dependency without changing the meaning of the system.Question9Consider relation R(X,Y,Z).Relation R currently has three tuples:(6,4,2),(6,6, 8)and(6,4,8).Which of the following three functional dependencies can you infer do not holdfor relation R?Explain your answer.Y→X4Z→YXY→ZAnswer.Thefirst functional dependency holds,but the rest do not hold.The second and third tuples both have8for Z but different values of Y.Thefirst and third tuples both have6and4for X and Y but different values for Z.Question10Consider the relation R(V,W,X,Y,Z)with functional dependencies{Z→Y,Y→Z,X→Y,X→V,V W→X}.a)List the possible keys for relation R based on the functional dependencies above.b)Show the closure for attribute X given the functional dependencies above.c)Suppose that relation R is decomposed into two relations,R1(V,W,X)and R2(X,Y,Z).Is this decomposition a lossless decomposition?Explain your answer.Answer.a.{V,W},{X,W}b.X+={X,V,Y,Z}c.Yes it is lossless.To be lossless the attributes in common between the two relations must functionally determine all the attributes in one of the two relations.The only attribute in common is X and it functionally determines all the attributes in R2.Question11Given relation R(W,X,Y,Z)and set of functional dependencies F={X→W,W Z→XY,Y→W XZ}.Compute the minimal cover for F.Answer.Step1:X→W,W Z→X,W Z→Y,Y→W,Y→X,Y→ZStep2:Don’t need W Z→X,since W Z→Y and Y→XDon’t need Y→W,since Y→X and X→WThis leaves{X→W W Z→Y,Y→X,Y→Z}Step3:Only need to consider W Z→Y.Can’t eliminate W or Z.So nothing is eliminated.Step4:{X→W W Z→Y,Y→XZ}is the minimal coverQuestion12Given relation R(W,X,Y,Z)and set of functional dependencies G={Z→W,Y→XZ,XW→Y},where G is a minimal cover:a)Decompose R into a set of relations in Third Normal Form.b)Is your decomposition in part a)also in Boyce Codd Normal Form?Explain your answer. Answer.a.Possible keys:{Y},{X,Z},{W,X}R1=(Z,W),R2=(X,Y,Z),R3=(X,Y,W)b.Yes.In each of the three relations,the left side of the funcational dependencies that apply are superkeys for the relation.Hence,all three relations satisfy the definition of BCNF.Question13Consider a relation named EMP DEPT with attributes:ENAME,SSN,BDATE, ADDRESS,DNUMBER,DNAME,and DMGRSSN.Consider also the set G of functional depen-dencies for EMP DEPT:5G={SSN→ENAME BDAT E ADDRESS DNUMBER,DNUMBER→DNAME,DMGRSSM}.a)Calculate the closures SSN+and DNAME+with respect to G.b)Is the set of functional dependences G minimal?If not,find a minimal set of functional depen-dencies that is equivalent to G.c)List an update anomaly that can occur for relation EMP DEPT.d)List an insertion anomaly that can occur for relation EMP DEPT.e)List a deletion anomaly that can occur for relation EMP DEPT.Answer.a)SSN+={SSN,ENAME,BDAT E,ADDRESS,DNUMBER,DNAME,DMGRSSN}DNAME+={DNAME}b)It is minimal.c)Since every member of a department has a reference to the manager of that department(i.e., Dmgrssn),when the department manager changes this reference must be changed multiple places.This leads to the possibility of an inconsistency in the database if they are not all changed.d)You cannot enter data about a department until you have employees for the department.e)If you delete the last employee for a department,you lose all information about the department. Question14You are given the following functional dependencies for the”EMPLOYEE”relation. Explain whether the relation”EMPLOYEE”is BCNF and3NF?Database:EMPLOYEE(ssn,first-name,last-name,address,date-joined,supervisor-ssn) DEPARTMENT(dept-no,name,manager-ssn)WORKS-IN(employee-ssn,dept-no)INVENTORY(dept-no,item-id,quantity)ITEMS(item-id,item-name,type)Foreign keys:1.EMPLOYEE.supervisor-ssn and WORKS-IN.employee-ssn point to EMPLOYEE.ssn.2.WORKS-IN.dept-no and INVENTORY.dept-no point to DEPARTMENT.dept-no.3.INVENTORY.item-id points to ITEMS.item-id.{ssn→supervisor−ssn,ssn→first−name,ssn→last−name,ssn→date−joined,ssn→address,address→ssn}.Answer.In BCNF,since ssn and address are both keys of EMPLOYEE.6。

考研数据库试题及答案

考研数据库试题及答案

考研数据库试题及答案一、选择题1. 数据库管理系统(DBMS)的主要功能不包括以下哪项?A. 数据存储B. 数据查询C. 数据加密D. 数据备份答案:C2. 在关系数据库中,以下哪个概念用于表示数据表之间的关系?A. 索引B. 视图C. 外键D. 触发器答案:C3. SQL语言中的“SELECT”语句用于执行哪种操作?A. 数据更新B. 数据删除C. 数据查询D. 数据插入答案:C二、填空题4. 数据库的三大范式包括第一范式(1NF)、第二范式(2NF)和第三范式(3NF)。

其中,第一范式要求表中的每一列都是不可分割的基本数据项,即表中的每一列都应该只包含______。

答案:原子值5. 在数据库设计中,使用ER图(实体-关系图)可以帮助我们理解和设计数据库的______。

答案:结构三、简答题6. 简述数据库事务的四个基本特性(ACID属性)。

答案:数据库事务的四个基本特性包括:- 原子性(Atomicity):事务中的所有操作要么全部完成,要么全部不完成,不会结束在中间某个点。

- 一致性(Consistency):事务必须保证数据库从一个一致的状态转移到另一个一致的状态。

- 隔离性(Isolation):并发执行的事务之间不会互相影响。

- 持久性(Durability):一旦事务提交,则其所做的修改将永久保存在数据库中,即使系统发生故障。

7. 解释什么是数据库的规范化以及它的目的是什么。

答案:数据库规范化是一种用于减少数据冗余和提高数据完整性的数据库设计技术。

它的目的是为了组织数据,确保数据库的结构对于用户来说是逻辑上合理的,并且可以有效地减少数据的存储空间和提高查询效率。

四、计算题8. 给定一个关系数据库表R(A, B, C, D),其中A是主键。

如果需要查询所有在字段B中具有相同值的记录,请写出相应的SQL查询语句。

答案:SELECT A, B, C, D FROM R GROUP BY B;9. 如果需要删除表R中所有B字段值为特定值x的记录,请写出相应的SQL删除语句。

数据库规范化练习

数据库规范化练习
工程号
材料号
数量
开工日期
完工日期
价格
P1
I1
4
2000.5
2001.5
250
P1
I2
6
2000.5
2001.5
300
P1
I3
15
2000.5
2001.5
180
P2
I1
6
2000.11
2001.12
250
P2
I4
18
2000.11
2001.12
350
任务3:设有如下所示的关系R。
(1)它为第几范式?为什么?
教师编号
教师名
课程名
系名
2013010101
李军
0101
00001
2013010102
刘强
0101
00001
2013010201
金山
0102
00002
2013010202
宋海
0102
00002
2013010301
王华
0103
00003
2013010401
张红
0104
00004
2013010402
曾键
教师编号
教师名
教师地址
2013011
马千里
D1
2013012
于得水
D1
2013013
余快
D2
课程编号
教师编号
课程名
010101
2013011
C1
010102
2013012
C2
010103
2013013
C3
010104
2013012

数据库的三大范式例题

数据库的三大范式例题

下面是数据库的三大范式的例题:
1. 第一范式(1NF):
考虑一个学生表,包含以下字段:学生ID、姓名、性别、课程1、课程2、课程3。

这个表不符合第一范式,因为课程字段重复且可能存在多个值。

修复后的第一范式表应该将课程抽取出来,形成一个独立的课程表和学生表,以实现单一信息的存储。

学生表:
学生ID、姓名、性别
课程表:
学生ID、课程
2. 第二范式(2NF):
考虑一个订单表,包含以下字段:订单ID、产品名称、产品分类、订单数量、单位价格、客户ID、客户姓名。

该表不符合第二范式,因为部分字段依赖于非码主键。

修复后的第二范式表应该将产品分类分离出来,与产品信息表关联。

订单表:
订单ID、产品ID、订单数量、单位价格、客户ID
产品信息表:
产品ID、产品名称、产品分类
客户表:
客户ID、客户姓名
3. 第三范式(3NF):
考虑一个图书馆借阅记录表,包含以下字段:读者ID、读者姓名、图书ID、图书名称、图书作者。

该表不符合第三范式,因为图书作者字段依赖于非码主键。

修复后的第三范式表应该将图书作者分离出来,与图书信息表关联。

读者表:
读者ID、读者姓名
借阅记录表:
读者ID、图书ID
图书信息表:
图书ID、图书名称、图书作者
通过将冗余数据分离到不同的表中,并使用外键关联这些表,我们可以实现符合第一范式、第二范式和第三范式的数据库设计。

第三范式例题

第三范式例题

第三范式例题
第三范式(3NF)是数据库规范化的一种形式,它是为了消除数据冗余和改善数据完整性而进行的。

在第三范式中,每个非主属性都完全函数依赖于整个候选键。

以下是一个第三范式的例题:
考虑一个公司,该公司的员工有以下信息:员工编号、员工姓名、部门、工资。

现在的问题是,这些信息应该如何存储以避免数据冗余并保持数据的完整性?
首先,我们可以将员工的信息分为三个表:员工表、部门表和工资表。

1. 员工表:员工编号、员工姓名、部门编号
2. 部门表:部门编号、部门名称
3. 工资表:员工编号、工资
现在,让我们看看这些表是否满足第三范式的要求:
在员工表中,员工编号是主键,非主属性是员工姓名和部门编号。

因为部门编号完全依赖于员工编号(每个员工的部门编号都是唯一的),所以这个表满足第三范式的要求。

在部门表中,部门编号是主键,非主属性是部门名称。

因为部门名称完全依赖于部门编号(每个部门的名称都是唯一的),所以这个表也满足第三范式的要求。

在工资表中,员工编号是主键,非主属性是工资。

因为工资完全依赖于员工编号(每个员工的工资都是唯一的),所以这个表也满足第三范式的要求。

因此,通过将数据分为三个表并确保每个非主属性都完全依赖于整个候选键,我们实现了第三范式,从而避免了数据冗余并保持了数据的完整性。

数据库原理--范式习题

数据库原理--范式习题

1.(8分)假设某公司销售业务中使用的订单格式如下:订单号:1145订货日期:09/15/2002 客户编号:1001客户名称:ABC 客户电话:8141763产品编号品名价格数量金额A 电源100.00 20 2000.00B 电表200.00 40 8000.00C 卡尺40.00 50 2000.00总金额:12000.00公司的业务规定:(1)订单号是唯一的,每张订单对应一个订单号;(2)一张订单可以订购多种产品,每一种产品可以在多个订单中出现;(3)一张订单有一个客户,且一个客户可以有多张订单;(4)每一个产品编号对应一种产品的品名和价格;(5) 每一个客户有惟一的客户编号。

试根据上述表格和业务规则设计关系模式:R(订单号,订货日期,客户编号,客户名称,客户电话,产品编号,品名,价格,数量)(1)指出该关系模式中的基本函数依赖(2)指出该关系模式的范式级别(要求按照各范式定义简要分析)(3)按3NF的定义将其分解为3NF,要求无损联结并保持函数依赖2.假设某企业集团数据库中有一关系模式R如下:R(商店编号,商品编号,商品库存数量,部门编号,负责人)如果规定:(1)每个商店的每种商品只在该商店的一个部门销售;(2)每个商店的每个部门只有一个负责人;(3)每个商店的每种商品只有一个库存数量。

试分析:(4)根据上述规定,写出关系模式R的基本函数依赖;(5)指出该关系模式R的候选码(6)指出该关系模式R的范式级别,为什么?若R不是3NF,将R分解为3NF。

3.建立一个描述学生情况的数据库:一个系有若干学生,但一个学生只属于一个系;一个系只有一名负责人;一个学生可以选修多门课程,每门课程有若干学生选修;每个学生学习每一门课程有一个成绩;学生(用学号SNO描述);系(用系名SDEPT描述);系负责人(用其姓名MN描述);课程(用课程名CNAME描述);成绩(G);假定建立了如下关系模式S(SNO, SEDPT, MN, CNAME, G) 试分析:(1)指出该关系模式中的函数依赖(2)指出该关系模式的范式级别(要求按照各范式定义简要分析)按3NF的定义将其分解为3NF,要求无损联结并保持函数依赖(要求解题过程)。

关系的范式习题(含答案解析)

关系的范式习题(含答案解析)

第4章 关系数据库的规范化理论
9
(3)分解为两个关系,使之达到3NF; 职工(职工号,职工名,年龄,性别,部门号) 部门(部门号,部门名称) (4)分解后的关系可以避免上述操作异常问题。 当增加一个新部门,而该部门还没有员工时,仍然 可以向部门关系中加入该部门信息,从而解决了 插入异常问题。 当某部门只有一名员工,删除该员工时,直接删除 职工关系中的该行信息即可。 不再会把该部门的 信息也删除,从而解决了删)如果R不属于3NF,请将R分解成3NF。 R(商店编号,商品编号,商品库存数量,部门编号,部门负责人) 每个商店的每种商品只在该商店的一个部门销售 (商店编号,商品编号)部门编号 每个商店的每个部门只有一个部门负责人 (商店编号,部门编号)部门负责人 每个商店的每种商品只有一个库存数量 (商店编号,商店编号)商品库存数量 R1(商店编号,商品编号,部门编号,商品库存数量) R2(商店编号,部门编号,部门负责人)
第4章 关系数据库的规范化理论
2
[解答] (1) R(商店编号,商品编号,商品库存数量,部门编号, 部门负责人) 每个商店的每种商品只在该商店的一个部门销售 (商店编号,商品编号)部门编号 每个商店的每个部门只有一个部门负责人 (商店编号,部门编号)部门负责人 每个商店的每种商品只有一个库存数量 (商店编号,商店编号)商品库存数量
关系范式习题
第4章 关系数据库的规范化理论
1
[例]假设某商业集团数据库中有一关系模式R如下: R(商店编号、商品编号、商品库存数量、部门编号、部门负 责人) 如果规定: 每个商店的每种商品只在该商店的一个部门销售。 每个商店的每个部门只有一个部分负责人 每个商店的每种商品只有一个库存数量。 请回答以下问题: (1) 根据上述规定,写出关系模式R的基本函数依赖。 (2) 找出关系模式R的候选码。 (3) 关系模式R最高已经达到第几范式?为什么? (4) 如果R不属于3NF,请将R分解成3NF。
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

1、请简述满足1NF、2NF和3NF的基本条件。

并完成下题:某信
息一览表如下,其是否满足3NF,若不满足请将其化为符合3NF 的关系。

(本小题12分)
第一范式的关系应满足的基本条件是元组中的每一个分量都必须是不可分割的数据项。

第二范式,指的是这种关系不仅满足第一范式,而且所有非主属性完全依赖于其主码。

第三范式,指的是这种关系不仅满足第二范式,而且它的任何一个非主属性都不传递依赖于任何主关键字。

考生情况(考生编号,姓名,性别,考生学校)
考场情况(考场号,考场地点)
考场分配(考生编号,考场号)
成绩(考生编号,考试成绩,学分)
2、某信息一览表如下,其是否满足3NF,若不满足请将其化为符
合3NF的关系。

(12分)
配件关系:(配件编号,配件名称,型号规格)
供应商关系(供应商名称,供应商地址)
配件库存关系(配件编号,供应商名称,单价,库存量)
3、简述满足1NF、2NF和3NF的基本条件。

并完成下题:已知教学关系,
教学(学号,姓名,年龄,性别,系名,系主任,课程名,成绩),试
问该关系的主键是什么,属于第几范式,为什么如果它不属于3NF,请把它规范到3NF。

4、请确定下列关系的关键字、范式等级;若不属于3NF,则将其化为3NF 。

例 1.仓库(仓库号,面积,电话号码,零件号,零件名称,规格,库存数量)
例1答案:
仓库号+零件号;1NF;
仓库(仓库号,面积,电话号码)
零件(零件号,零件名称,规格)
保存(仓库号,零件号,库存数量)
例2. 报名(学员编号,学员姓名,培训编号,培训名称,培训费,报名日期),每项培训有多个学员报名,每位学员可参加多项培训。

例2答案:
学员编号+培训编号;1NF;
学员(学员编号,学员姓名)
培训(培训编号,培训名称,培训费)
报名(学员编号,培训编号,报名日期)
5、请确定下列关系的关键字、范式等级;若不属于3NF,则将其化为3NF,要求每个关系写一条记录。

(部门编号,部门名称,所在城市,员工编号,员工姓名,项目编号,项目名称,预算,职务,加入项目的日期)
[注]职务指某员工在某项目中的职务。

部门(部门编号,部门名称,所在城市)
员工(员工编号,员工姓名,部门编号)
项目(项目编号,项目名称,预算)
工作(员工编号,项目编号,职务,加入项目的日期)。

相关文档
最新文档