数据库设计(七)第三范式(3NF)
In our last tutorial, we learned about the second normal form and even normalized our Score table into the 2nd Normal Form.
So let's use the same example, where we have 3 tables, Student, Subject and Score.
Student Table
Subject Table
Score Table
In the Score table, we need to store some more information, which is the exam name and total marks, so let's add 2 more columns to the Score table.
Requirements for Third Normal Form
For a table to be in the third normal form,
- It should be in the Second Normal form.
- And it should not have Transitive Dependency.
What is Transitive Dependency?
With exam_name
and total_marks
added to our Score table, it saves more data now. Primary key for our Score table is a composite key, which means it's made up of two attributes or columns → student_id + subject_id.
Our new column exam_name
depends on both student and subject. For example, a mechanical engineering student will have Workshop exam but a computer science student won't. And for some subjects you have Prctical exams and for some you don't. So we can say that exam_name
is dependent on both student_id
and subject_id
.
And what about our second new column total_marks
? Does it depend on our Score table's primary key?
Well, the column total_marks
depends on exam_name
as with exam type the total score changes. For example, practicals are of less marks while theory exams are of more marks.
But, exam_name
is just another column in the score table. It is not a primary key or even a part of the primary key, and total_marks
depends on it.
This is Transitive Dependency. When a non-prime attribute depends on other non-prime attributes rather than depending upon the prime attributes or primary key.
How to remove Transitive Dependency?
Again the solution is very simple. Take out the columns exam_name
and total_marks
from Score table and put them in an Exam table and use the exam_id
wherever required.
Score Table: In 3rd Normal Form
The new Exam table
Advantage of removing Transtive Dependency
The advantage of removing transtive dependency is,
- Amount of data duplication is reduced.
- Data integrity achieved.
数据库设计(七)第三范式(3NF)的更多相关文章
- BCNF/3NF 数据库设计范式简介
数据库设计有1NF.2NF.3NF.BCNF.4NF.5NF.从左往右,越后面的数据库设计范式冗余度越低. 满足后一个设计范式也必定满足前一个设计范式. 1NF只要求每个属性是不可再分的,基本每个数据 ...
- 七、Oracle 数据库设计
1. 原始单据与实体之间的关系 可以是一对一.一对多.多对多的关系.在一般情况下,它们是一对一的关系:即一张原始单据对应且只对应一个实体. 在特殊情况下,它们可能是一对多或多对一的关系,即一张原始单证 ...
- Oracle数据库设计第三范式
一.数据库设计范式及其意义和不足 数据库的设计范式是数据库设计所需要满足的规范,数据库的规范化是优化表的结构和优化把数据组织到表中的方式,这样使数据更明确,更简洁.实践中,通常把一个数据库分成两个或多 ...
- 优化MySchool数据库设计之【巅峰对决】
优化MySchool数据库设计 之独孤九剑 船舶停靠在港湾是很安全的,但这不是造船的目的 By:北大青鸟五道口原玉明老师 1.学习方法: 01.找一本好书 初始阶段不适合,可以放到第二个阶段,看到知识 ...
- 优化MySchool数据库设计总结
数据库的设计 一:什么是数据库设计? 数据库设计就是将数据库中的数据实体以及这些数据实体之间的关系,进行规范和结构化的过程. 二:为什么要实施数据库设计? 1:良好的数据库设计可以有效的解决数据冗 ...
- 数据库设计范式1——三范式
一讲到数据库设计,大家很容易想到的就是三范式,但是第四.第五范式又是什么,不是很清楚,三范式到底怎么区分,也不清楚,作为数据库设计的基础概念,我再讲解下数据库范式. Normal form Bri ...
- S2--《优化MySchool数据库设计》总结
第一章 数据库的设计 1.1 数据库设计 数据库中创建的数据库结构的种类,以及在数据实体之间建立的复杂关系是决定数据库系统效率的重要因素. 糟糕的数据库设计表现在以下两个方面: *效率低下 * ...
- MySQL 数据库设计 笔记与总结(2)逻辑设计
[实例演示 —— 实体之间的关系] [逻辑设计的工作] ① 将需求转化为数据库的逻辑模型 ② 通过 ER 图的形式对逻辑模型进行展示 ③ 同所选用的具体的 DBMS 系统无关 [名词解释] 候选码可以 ...
- MySQL优化技巧之四(数据库设计中的一些技巧)
1. 原始单据与实体之间的关系 可以是一对一.一对多.多对多的关系.在一般情况下,它们是一对一的关系:即一张原始单据对应且只对应一个实体.在特殊情况下,它们可能是一对多或多对一的关系,即一张原始单证对 ...
- SQL Server 数据库设计
一.数据库设计的必要性 在实际的软件项目中,如果系统中需要存储的数据量比较大,需要设计的表比较多,表与表之间的关系比较复杂,那我们就需要进行规范的数据库设置.如果不经过数据库的设计,我们构建的数据库不 ...
随机推荐
- 捕获和记录SQL Server中发生的死锁
经带在论坛上看到有人在问怎么捕获和记录死锁信息,在这里,我将自己的一些心得贡献出来,与大家分享,也请各位指正. 我们知道,可以使用SQL Server自带的Profiler工具来跟踪死锁信息.但这种方 ...
- VLAN讲解
VLAN(Virtual Local Area Network)的中文名为"虚拟局域网".VLAN是一种将局域网设备从逻辑上划分成一个个网段,从而实现虚拟工作组的新兴数据交换技术. ...
- OSG立体模式下动态修改相机远近裁剪面的实现
1. 非立体模式下动态修改相机远近裁剪面 class GLB_DLLCLASS_EXPORT CGlbGlobeClipHandler : public osg::NodeCallback { ...
- springmvc怎么重定向,从一个controller跳到另一个controller
第一种情况,不带参数跳转: 方法一:使用ModelAndView return new ModelAndView("redirect:/toList"); 这样可以重定向到toL ...
- Java实现文件MD5加密
代码实现: import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.s ...
- Android面试题(2)
1.activity的生命周期 方法 描述 可被杀死 下一个 onCreate() 在activity第一次被创建的时候调用.这里是你做所有初始化设置的地方──创建视图.设置布局.绑定数据至列表等.如 ...
- 【Linux】Ubuntu vi 上下左右变ABCD及 apt-get install报错问题解决方法
新装的ubuntu12.04,本人绝对新手,在使用VI编辑器编辑文本时觉得实在是难用,因此找了几个解决方法如下: 1. 安装vim full版本 由于Ubuntu预安装的是tiny版本,就会导致我们在 ...
- 安装PIL的坑
今天在centos中使用pip安装PIL死活不成功,报错: Could not find a version that satisfies the requirement PIL (from vers ...
- Office办公 如何打印顺丰发票
1 关注顺丰速递,我-我的钱包 2 我的钱包-发票申请 3 勾选要打印发票的项目,点击申请发票 4 点击提交,确认发送的邮箱(他是把PDF发到指定邮箱) 最后PDF效果如下 ...
- poj 2253 (dis最短路径)
Frogger Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 24979 Accepted: 8114 Descript ...