数据库设计(七)第三范式(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 数据库设计
一.数据库设计的必要性 在实际的软件项目中,如果系统中需要存储的数据量比较大,需要设计的表比较多,表与表之间的关系比较复杂,那我们就需要进行规范的数据库设置.如果不经过数据库的设计,我们构建的数据库不 ...
随机推荐
- phantomjs 无法打开https网站解决方案
最近测试原来的爬虫程序,发现phantomjs 无法打开https网站了,经过网上查下,发现需要在phantomjs定义的加以下参数 self.driver = webdriver.PhantomJS ...
- 推断是否是有效的IP地址
#include<stdio.h> #include<string.h> bool isValidIp(char *s) { int len=strlen(s); int i= ...
- 转: APK签名校验绕过
转: http://drops.wooyun.org/mobile/4296 APK签名校验绕过 3xpl0it · 2014/12/11 10:41 0x01 Android签名机制 将APK重命名 ...
- [CSS3] Make a One-time CSS Animation that Does Not Revert to its Original Style
We'll add animation to patio11bot using CSS keyframes. When defining a CSS animation, you can add it ...
- java中调用kettle转换文件
java中调用kettle转换文件 通过命令行也能够调用,然后java中调用命令行代码也能够.这样没有和java代码逻辑无缝集成.本文说明kettle5.1中假设通过其它API和java代码无缝集成: ...
- ffmpeg代码解析
void avdevice_register_all(void){ static int initialized; if (initialized) return; i ...
- LoadRunner录制: 选择协议
LR录制的时候关心的是通信,关心的是客户端和服务器之间的数据包.它通过监控客户端和服务器之间的通信,转化为自己的函数. 协议选择错误,可能会导致录制下来的内容为空. 方法一:根据经验来选择协议 Web ...
- UIImagePickerController 视频录制操作,视频大小,时间长度
一:使用 iOS 系统 UIImagePickerController 获取视频大小 获取视频长度 - (void)viewDidLoad { [super viewDidLoad]; // Do a ...
- 【转】iBatis简单入门教程
1. iBatis 简介: iBatis 是apache 的一个开源项目,一个O/R Mapping 解决方案,iBatis 最大的特点就是小巧,上手很快.如果不需要太多复杂的功能,iBatis 是能 ...
- javascript Date日期类
四.Date日期类 迁移时间:2017年5月27日18:43:02 Author:Marydon (一)对日期进行格式化(日期转字符串) 自定义Date日期类的format()格式化方法 方式一: ...