数据库设计(四)数据库的规范化(Normalization)
数据库的规范化
Database Normalization is a technique of organizing the data in the database. Normalization is a systematic(系统的) approach of decomposing(分解) tables to eliminate data redundancy(repetition) and undesirable(不可取的,不受欢迎的) characteristics like Insertion, Update and Deletion Anamolies(原文写错了,应该是Anomalies,异常,异常情况). It is a multi-step process that puts data into tabular(扁平的,表格式的) form, removing duplicated data from the relation tables.
Normalization is used for mainly two purposes,
- Eliminating reduntant(useless) data.
- Ensuring data dependencies make sense i.e data is logically stored.
Problems Without Normalization
If a table is not properly normalized and have data redundancy then it will not only eat up extra memory space but will also make it difficult to handle and update the database, without facing data loss. Insertion, Updation and Deletion Anamolies are very frequent if database is not normalized. To understand these anomalies let us take an example of a Student table.
In the table above, we have data of 4 Computer Sci. students. As we can see, data for the fileds branch
, hod
(Head of Department) and office_tel
is repeated for the students who are in the same branch in the college, this is Data Redundancy(数据冗余).
Insertion Anomaly
Suppose for a new admission, until and unless a student opts for a branch, data of the student cannot be inserted, or else we will have to set the branch information as NULL.
Also, if we have to insert data of 100 students of same branch, then the branch information will be repeated for all those 100 students.
These scenarios are nothing but Insertion anomalies.
Updation Anomaly
What if Mr. X leaves the college? or is no longer the HOD of computer science department? In that case all the student records will have to be updated, and if by mistake we miss any record, it will lead to data inconsistency. This is Updation anomaly.
Deletion Anomaly
In our Student table, two different informations are kept together, Student information and Branch information. Hence, at the end of the academic year, if student records are deleted, we will also lose the branch information. This is Deletion anomaly.
Normalization Rule
Normalization rules are divided into the following normal forms:
- First Normal Form
- Second Normal Form
- Third Normal Form
- BCNF
First Normal Form (1NF)
For a table to be in the First Normal Form, it should follow the following 4 rules:
- It should only have single(atomic) valued attributes/columns.
- Values stored in a column should be of the same domain
- All the columns in a table should have unique names.
- And the order in which data is stored, does not matter.
In the next tutorial, we will discuss about the First Normal Form in details.
Second Normal Form (2NF)
For a table to be in the Second Normal Form,
- It should be in the First Normal form.
- And, it should not have Partial Dependency.
To understand what is Partial Dependency and how to normalize a table to 2nd normal for, jump to the Second Normal Form tutorial.
Third Normal Form (3NF)
A table is said to be in the Third Normal Form when,
- It is in the Second Normal form.
- And, it doesn't have Transitive Dependency(依赖传递).
Here is the Third Normal Form tutorial. But we suggest you to first study about the second normal form and then head over to the third normal form.
Boyce and Codd Normal Form (BCNF)
Boyce and Codd Normal Form is a higher version of the Third Normal form. This form deals with certain type of anomaly that is not handled by 3NF. A 3NF table which does not have multiple overlapping candidate keys is said to be in BCNF. For a table to be in BCNF, following conditions must be satisfied:
- R must be in 3rd Normal Form
- and, for each functional dependency ( X → Y ), X should be a super Key.
最后一个范式看着有点蛋疼呀。
数据库设计(四)数据库的规范化(Normalization)的更多相关文章
- sql数据库设计学习---数据库设计规范化的五个要求
http://blog.csdn.net/taijianyu/article/details/5945490 一:表中应该避免可为空的列: 二:表不应该有重复的值或者列: 三: 表中记录应该有一个唯一 ...
- 2017(2)数据库设计,数据库设计过程,ER模型,规范化理论
试题二(共 25 分〉 阅读以下关于系统数据分析与建模的叙述,在答题纸上回答问题1 至问题 3. [说明] 某软件公司受快递公司委托,拟开发一套快递业务综合管理系统,实现快递单和物流信息的综合管理.项 ...
- 【SQL数据库设计】数据库设计【小型数据库】
数据库设计 需求 表结构 字段类型.是否允许为null.是否有默认值 索引设计 数据库引擎的选择 根据产品原型分析,词性分析法,名词创建表或字段,动词表示关系. 数据存储:长期存储的数据, 1.主键: ...
- 数据库设计-Mysql数据库表设计的过程中几个关键点
一.表设计过程中应该注意的数据类型 1)更小的通常更好 控制字节长度 2)使用合适的数据类型: 如tinyint只占8个位,char(1024)与varchar(1024)的对比,char用于类似定长 ...
- ylbtech-czgfh(规范化)-数据库设计
ylbtech-DatabaseDesgin:ylbtech-czgfh(规范化)-数据库设计 DatabaseName:czgfh(财政规范化) Model:账户模块.系统时间设计模块.上报自评和审 ...
- MySQL学习07(规范化数据库设计)
规范化数据库设计 当数据库比较复杂时我们需要设计数据库 糟糕的数据库设计 : 数据冗余,存储空间浪费 数据更新和插入的异常 程序性能差 良好的数据库设计 : 节省数据的存储空间 能够保证数据的完整性 ...
- SQL Server 数据库设计
一.数据库设计的必要性 在实际的软件项目中,如果系统中需要存储的数据量比较大,需要设计的表比较多,表与表之间的关系比较复杂,那我们就需要进行规范的数据库设置.如果不经过数据库的设计,我们构建的数据库不 ...
- Mysql之数据库设计
一.三大范式 1.第一范式:消除一个字段包含多个数据库值,消除一个记录包含重复的组(单独的一列包含多个项目),即可满足1NF. 2.第二范式:消除部分依赖性即可转化为2NF.部分依赖性表示一个记录中包 ...
- 口罩预约管理系统——数据库设计(前端+PHP+MySQL)
目录 一.背景 二.口罩预约管理系统介绍 三.数据库设计 四.MySQL创建数据库以及数据表 五.数据库设计总结 一.背景 2020年的疫情影响了我们的生产生活,政府不断加大力度联防联控,遏制疫情的蔓 ...
- MySQL数据分析-(5)数据库设计之ER模型
大家好,我是jacky,很高兴跟大家分享本课时的内容,从本节课开始,就开始了我们第二章的学习,第一章我们抛出了若干问题,从第二章开始往后,都是解决问题的一个过程: 第一章的案例中,我们拿手机销售公司举 ...
随机推荐
- http://blog.sina.com.cn/s/blog_4dd787e40102uysg.html
http://blog.sina.com.cn/s/blog_4dd787e40102uysg.html
- ZOJ3622 Magic Number(水题)
分析: 举个样例xxx(三位数)为魔力数,则xxx|(xxx+1000*y),那么xxx|1000,这个就是结论 同理:四位数xxxx|10000,五位数xxxxx|100000 代码: #inclu ...
- SparkSQL之更改表结构
本文篇幅较短,内容源于自己在使用SparkSQL时碰到的一个小问题,因为在之后的数据处理过程中多次使用,所以为了加深印象,在此单独成文,以便回顾. 场景 在使用SparkSQL进行数据处理时,碰到这样 ...
- [CF 276C]Little Girl and Maximum Sum[差分数列]
题意: 给出n项的数列A[ ], q个询问, 询问 [ l, r ] 之间项的和. 求A的全排列中该和的最大值. 思路: 记录所有询问, 利用差分数列qd[ ], 标记第 i 项被询问的次数( 每次区 ...
- 会声会影X10 64位整合光盘V10.1.0.14简体中文版 下载
http://xiazai.huishenghuiying.com.cn/wm/huishenghuiyingx10_64bit_wmqm.exe
- App服务端架构变迁
随着移动互联网时代的到来,移动技术也随之飞速发展.如今,App已然成为绝大多数互联网企业用来获取用户的核心渠道.以往以PC为主要承载平台的各业务线,源源不断集成加入到移动项目中来,原本以产品为中心快速 ...
- Js、JQuery脚本兼容
1.获取属性值 IE:$("#xxx").prop("title"); chrome:$("#xxx").attr("title& ...
- SDL 学习及相关API
SDL_PeepEvents() 在事件队列中搜索特定类型的事件. int SDL_PeepEvents(SDL_Event *events, int numevents, SDL_eventacti ...
- vue 不能检测数组长度 值变化原因解析
1.vue不能检测数组长度或者值的变化 (1)数组长度变化 未检测到 <!DOCTYPE html> <html lang="en"> <head&g ...
- MediaWiki怎样重置用户password
今天.弄mediawiki因为一个周末另一夜没有睡觉导致忘记password了(欢迎吐槽~) 就開始折腾之旅,本来以为能够直接执行一条sql语句就都搞定了结果...依照网上大多数讲述的 我已经找不到原 ...