数据库规范化理论_数据库规范化

数据库规范化理论

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 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 redundant(useless) data.

    消除冗余(无用)数据。

  • Ensuring data dependencies make sense i.e data is logically stored.

    确保数据依赖性是有意义的,即数据是逻辑存储的。

The video below will give you a good overview of Database Normalization. If you want you can skip the video, as the concept is covered in detail, below the video.

下面的视频将为您很好地概述数据库规范化。 如果需要,可以跳过视频,因为在视频下方详细介绍了该概念。

演示地址

没有规范化的问题 (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 Anomalies are very frequent if database is not normalized. To understand these anomalies let us take an example of a Student table.

如果表未正确归一化并具有数据冗余,则它不仅会占用额外的内存空间,而且还会使处理和更新数据库变得困难,而不会导致数据丢失。 如果数据库未规范化,则插入,更新和删除异常非常常见。 为了理解这些异常,让我们以学生表为例。

rollnonamebranchhodoffice_tel
401AkonCSEMr. X53337
402BkonCSEMr. X53337
403CkonCSEMr. X53337
404DkonCSEMr. X53337
罗尔诺 名称 d office_tel
401 阿Kong 自学考试 X先生 53337
402 布Kong 自学考试 X先生 53337
403 自学考试 X先生 53337
404 德Kong 自学考试 X先生 53337

In the table above, we have data of 4 Computer Sci. students. As we can see, data for the fields 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.

在上表中,我们具有4计算机科学的数据。 学生们。 如我们所见,对于大学中同一分支中的学生,将重复字段branchhod (系主任)和office_tel 数据 ,这就是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.

假设要重新入学,除非学生选择分支机构,否则该学生的数据无法插入,否则我们将分支机构信息设置为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.

另外,如果我们必须插入同一分支的100名学生的数据,则将对所有这100名学生重复分支信息。

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.

如果X先生离开大学怎么办? 还是不再是计算机科学系的HOD? 在这种情况下,所有学生记录都必须进行更新,如果由于错误而错过了任何记录,则将导致数据不一致。 这是更新异常。

删除异常 (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:

规范化规则分为以下正常形式:

  1. First Normal Form

    第一范式

  2. Second Normal Form

    第二范式

  3. Third Normal Form

    第三范式

  4. BCNF

    BCNF

  5. Fourth Normal Form

    第四范式

第一范式(1NF) (First Normal Form (1NF))

For a table to be in the First Normal Form, it should follow the following 4 rules:

为使表格处于“第一范式”,它应遵循以下4条规则:

  1. It should only have single(atomic) valued attributes/columns.

    它应该仅具有单个(原子)值的属性/列。

  2. Values stored in a column should be of the same domain

    列中存储的值应属于同一域

  3. All the columns in a table should have unique names.

    表中的所有列应具有唯一的名称。

  4. 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.

在下一个教程中,我们将详细讨论“ 第一范式”

第二范式(2NF) (Second Normal Form (2NF))

For a table to be in the Second Normal Form,

要将表格设为第二范式,

  1. It should be in the First Normal form.

    它应该是“第一范式”形式。

  2. 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.

要了解什么是部分依赖关系以及如何将表标准化为第二范式,请跳至第二范式教程。

第三范式(3NF) (Third Normal Form (3NF))

A table is said to be in the Third Normal Form when,

在以下情况下,表格称为“第三范式”:

  1. It is in the Second Normal form.

    它是第二范式的形式。

  2. 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.

这是第三范式教程。 但是我们建议您先研究第二种正规形式,然后再学习第三种正规形式。

博伊斯和科德范式(BCNF) (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:

博伊斯和科德范式是第三范式的更高版本。 此表格处理3NF无法处理的某些类型的异常。 没有多个重叠候选键的3NF表被称为BCNF。 为了使表位于BCNF中,必须满足以下条件:

  • R must be in 3rd Normal Form

    R必须为第三范式

  • and, for each functional dependency ( X → Y ), X should be a super Key.

    并且,对于每个功能依赖项(X→Y),X应该是一个超级键。

To learn about BCNF in detail with a very easy to understand example, head to Boye-Codd Normal Form tutorial.

要通过一个非常容易理解的示例详细了解BCNF,请转到Boye-Codd Normal Form教程。

第四范式(4NF) (Fourth Normal Form (4NF))

A table is said to be in the Fourth Normal Form when,

当一个表被称为第四范式时,

  1. It is in the Boyce-Codd Normal Form.

    它采用的是Boyce-Codd范式。

  2. And, it doesn't have Multi-Valued Dependency.

    而且,它没有多值依赖。

Here is the Fourth Normal Form tutorial. But we suggest you to understand other normal forms before you head over to the fourth normal form.

这是第四范式教程。 但是我们建议您在进入第四个范式之前先了解其他范式。

翻译自: https://www.studytonight.com/dbms/database-normalization.php

数据库规范化理论

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值