1NF 2NF 3NF DBMS

Saghir School
18 Jun 202008:31

Summary

TLDRThis script emphasizes the importance of normalization in database design to reduce data redundancy and enhance security. It outlines the process of achieving different normal forms: First Normal Form by eliminating repeating values or groups, Second Normal Form by resolving partial dependencies in composite keys, and Third Normal Form by eliminating transitive dependencies. Each step is crucial for creating a flexible, secure, and efficient database structure.

Takeaways

  • 📚 Normalization is crucial in database design to reduce data redundancy and improve data organization.
  • 🔐 Database security is enhanced through normalization as it involves creating more tables which can restrict access to sensitive data.
  • 📈 The process of normalization should follow a sequence: First Normal Form (1NF), Second Normal Form (2NF), and then Third Normal Form (3NF).
  • 🚫 A table in 1NF must avoid repeating values within a group and repeating groups within the table.
  • 🔑 To achieve 1NF, if a table has repeating values or columns, these should be separated into distinct tables and linked appropriately.
  • 🔄 Composite keys, which consist of more than one column, can lead to partial dependencies and are a consideration for 2NF.
  • 📝 For a table to be in 2NF, it must be in 1NF and have no partial dependencies where non-key columns depend only on part of the composite key.
  • 🔄 In 3NF, tables must be in both 1NF and 2NF, and there should be no transitive dependencies where non-key columns depend on other non-key columns.
  • 🔍 Identifying and removing transitive dependencies, such as guessing one non-key column from another, is essential for achieving 3NF.
  • 💡 Examples provided in the script, such as employee phone numbers, student results, and match capacities, illustrate how to apply normalization rules in real-world scenarios.

Q & A

  • What is the primary purpose of normalization in database design?

    -The primary purpose of normalization in database design is to reduce data redundancy and improve data integrity by organizing data into well-structured tables.

  • Why is it important to follow the sequence of normalization forms when designing a database?

    -Following the sequence of normalization forms is important because each form builds upon the previous one. You cannot bypass earlier forms and directly go to a higher normal form, as each step ensures the database adheres to specific structural rules that prevent data anomalies.

  • What are the two criteria that a table must meet to be in the first normal form?

    -A table must meet two criteria to be in the first normal form: it should not have repeating values in a group, and it should not have repeating groups in the table.

  • How does the example of an employee table with multiple phone numbers violate the first normal form?

    -The example of an employee table with multiple phone numbers violates the first normal form by having repeating values in a column, as the phone numbers are listed in a single column, which goes against the rule of having no repeating groups.

  • What is a composite key and why is it necessary in a database?

    -A composite key is a primary key composed of more than one column, used when a single column is not sufficient to uniquely identify a record. It is necessary to ensure that each record in the database can be uniquely identified.

  • Can you explain partial dependency and how it relates to the second normal form?

    -Partial dependency occurs when a non-key column depends on only a part of a composite key rather than the entire key. To achieve the second normal form, the table must be free from partial dependencies, ensuring that non-key columns depend on the entire primary key.

  • What is a transitive dependency and how does it violate the third normal form?

    -A transitive dependency occurs when a non-key column is dependent on another non-key column or when a non-key column can be determined from other non-key columns. This violates the third normal form, which requires that non-key columns should only depend on the primary key.

  • How does normalization affect database security?

    -Normalization can enhance database security by creating more tables that can be used to restrict access to sensitive information. By segmenting data into multiple tables, it becomes easier to implement security measures that control access to specific data sets.

  • What is the solution to the problem of repeating columns in a table?

    -The solution to the problem of repeating columns is to remove the columns that are causing the issue and create separate tables for those columns, then link them back to the original table using a foreign key.

  • Why is it beneficial for a database to handle more tables rather than having tables with repeating values or columns?

    -Handling more tables is beneficial because it adheres to the principles of normalization, which reduces redundancy and improves data integrity. Databases can efficiently manage multiple tables, but they struggle with performance and consistency when dealing with repeating values or columns.

Outlines

00:00

📚 Database Normalization Basics

This paragraph introduces the fundamental concept of normalization in database design. Normalization is a set of rules aimed at reducing data redundancy and improving data integrity. It involves creating more tables than in non-normalized forms, which can be managed more efficiently by a database system. The benefits of normalization include enhanced flexibility in design and improved database security, as it allows for the creation of tables that can restrict access to certain users. The paragraph explains the process of normalization, starting with the first normal form (1NF), which requires tables to have no repeating values or groups. An example is provided where an employee table is modified to avoid repeating phone numbers by creating a separate table for phone numbers linked to the employee table. The paragraph also touches on the sequential nature of normalization forms, where each subsequent form builds upon the previous one, and that one cannot skip forms in the normalization process.

05:01

🔐 Advanced Normalization Forms: 2NF and 3NF

The second paragraph delves into the specifics of the second (2NF) and third (3NF) normal forms in database normalization. For a table to be in 2NF, it must first be in 1NF and must not have partial dependencies, which occur when non-key columns depend on only a part of a composite key. An example is given where a table with student IDs and courses has a partial dependency issue, as the teacher column depends only on the course, not the student ID. To resolve this, the table is split to eliminate partial dependencies. The third normal form (3NF) requires a table to be in both 1NF and 2NF and to have no transitive dependencies, where a non-key column is dependent on another non-key column. Examples are provided to illustrate transitive dependencies, such as a table where the maximum marks column can be inferred from the exam type, or a table where the capacity of a stadium can be deduced from the ground name. The paragraph concludes by emphasizing that transitive dependencies, including those resulting from calculations within the table, must be eliminated to achieve 3NF.

Mindmap

Keywords

💡Normalization

Normalization is a process in database design aimed at organizing data to minimize redundancy and dependency. In the context of the video, normalization is crucial for creating a flexible and secure database structure. The script explains that normalization involves creating more tables to handle data more efficiently, which is beneficial for database performance and security. The video emphasizes that normalization should be approached step by step, starting from the first normal form and progressing to higher forms.

💡First Normal Form (1NF)

First Normal Form is the first step in the normalization process where a table is structured to have no repeating values or groups. The video uses the example of an employee table to illustrate how separating out phone numbers into a new table can resolve repeating values and achieve 1NF. This step is fundamental because it ensures that each record in a table is unique and can be easily accessed and modified.

💡Second Normal Form (2NF)

Second Normal Form builds upon 1NF by eliminating partial dependencies, which occur when a non-key column depends on only a part of a composite key. The video explains this with a student results table, where the 'teacher' column only depends on the 'course' part of the composite key, not the entire key. To achieve 2NF, the table is split to ensure that non-key columns are fully dependent on the entire primary key.

💡Composite Key

A composite key is a primary key consisting of two or more columns, used when a single column is not sufficient to uniquely identify a record. The video script uses the example of a student results table where both 'student id' and 'course' are needed to uniquely identify a student's record. The concept is integral to understanding 2NF, as it helps in identifying and resolving partial dependencies.

💡Partial Dependency

Partial dependency refers to a situation where a non-key column is dependent on only a part of a composite key, rather than the entire key. The video script explains this concept using a table where the 'teacher' column depends only on the 'course' and not on the 'student id', which is a part of the composite key. This dependency violates the rules of 2NF, and resolving it by restructuring the table is essential for normalization.

💡Third Normal Form (3NF)

Third Normal Form is the next level of normalization that eliminates transitive dependencies, where a non-key column is determined by another non-key column. The video provides examples such as a table where 'maximum marks' can be inferred from the 'exam type', violating 3NF. To achieve 3NF, the table is split to ensure that only the primary key determines the non-key columns, thus reducing redundancy and improving data integrity.

💡Transitive Dependency

Transitive dependency occurs when a non-key column can be determined by another non-key column, which is not directly related to the primary key. The video script uses examples like a sports match table where the 'capacity' of a ground can be inferred from the 'ground' column, indicating a transitive dependency that needs to be resolved to achieve 3NF.

💡Data Redundancy

Data redundancy refers to the duplication of data in a database, which can lead to inconsistencies and inefficiencies. The video script emphasizes that normalization, particularly 1NF, 2NF, and 3NF, helps in reducing data redundancy by structuring data in a way that each piece of information is stored only once and is easily accessible.

💡Database Security

Database security involves protecting data from unauthorized access and ensuring its integrity. The video script mentions that normalization contributes to database security by creating more tables, which can be managed to restrict access to sensitive information. This is particularly relevant when certain data needs to be hidden from some users, thus enhancing the overall security of the database system.

💡Flexibility

Flexibility in database design refers to the ease with which the database can be modified or expanded. The video script highlights that normalization increases flexibility by creating a structure that can accommodate changes more easily. For instance, adding a new type of data or modifying existing data becomes simpler and less disruptive in a normalized database.

💡Data Integrity

Data integrity ensures that data is accurate, consistent, and remains unchanged in the absence of intervention. The video script explains that normalization helps maintain data integrity by eliminating redundancy and dependencies that can lead to data inconsistencies. For example, by separating phone numbers into a separate table, the database ensures that each employee's phone numbers are accurately recorded and updated without affecting other records.

Highlights

Normalization is crucial for database design as it reduces data redundancy and increases table count.

Databases handle more tables efficiently than non-normalized forms, enhancing flexibility and security.

Advantages of normalization include increased design flexibility and improved database security.

Normalization forms must be followed sequentially, starting from the first normal form.

A table in the first normal form must avoid repeating values in a group and repeating groups in the table.

Example of an employee table in perfect form with employee ID as the primary key.

Handling multiple phone numbers for employees by separating them into different columns violates the first normal form.

Solution to repeating values is to create a separate table for phone numbers and connect it to the employee table.

A table in the second normal form must be in the first normal form and avoid partial dependencies.

Composite keys are used when there is more than one primary key column.

Partial dependency occurs when a non-key column depends on only part of the composite key.

To resolve partial dependency, break the dependent column into another table.

A table in the third normal form must be in the first and second normal forms and avoid transitive dependencies.

Transitive dependency occurs when a non-key column can be determined from other non-key columns.

Example of a student exam table where the maximum marks can be inferred from the exam type, violating third normal form.

Breaking the table to remove transitive dependency, such as maximum marks, and placing it in another table.

Transitive dependency also occurs with calculated values, such as earnings based on ticket sales and price.

Transcripts

play00:06

whenever designing

play00:08

database the most important thing that

play00:10

you need to do is to

play00:11

take care of the normalization rules by

play00:14

definition normalization says it reduces

play00:17

the

play00:17

data redundancy and creates more table

play00:20

than before

play00:21

well database can handle more tables

play00:24

rather than

play00:25

the tables that are not in normalized

play00:26

forms so making more tables

play00:28

is much more suitable for database

play00:30

rather than wrong tables

play00:32

well the advantages that normalization

play00:34

brings is

play00:35

flexibility designs flexibility database

play00:38

security database is much secure with

play00:40

normalization because

play00:41

more tables are formed and there are

play00:44

cases when you

play00:45

don't when you need some information to

play00:47

hide from some users so

play00:49

so it counts in data security reduces

play00:52

data redundancy in a much organized way

play00:54

these are the normalization types we'll

play00:56

talk about by the way when considering

play00:59

normalization forms you cannot bypass

play01:02

the previous form

play01:04

means first you have to go through first

play01:05

normal form then second normal form

play01:07

and then eventually third normal form

play01:09

you cannot bypass the first two and

play01:11

directly go to third one

play01:13

first normal form for a table to be in a

play01:16

first normal form it needs

play01:18

two criterias two things that should not

play01:20

happen in this table

play01:21

first no repeating values in a group and

play01:24

no repeating

play01:25

groups in the table what does that mean

play01:28

we'll see in the example

play01:30

in this example of the employee table it

play01:32

is in a perfect form

play01:34

employee id is the primary key and it

play01:36

has

play01:37

values of name address and phone number

play01:39

so far so good

play01:40

what if there's a possibility when

play01:42

employees having more than one phone

play01:44

number

play01:45

you can write them like this by

play01:47

separating with the columns that's

play01:48

repeating values in a column

play01:50

and it's violating the first normal form

play01:53

the other possibility of writing it

play01:55

writing them in different columns

play01:57

and that's repeating columns repeating

play02:00

columns

play02:01

again violates the first normal form

play02:03

remember what we gathered from the

play02:04

definition of first normal form

play02:06

table cannot be in a first normal form

play02:08

if it contains repeating values or

play02:10

repeating columns repeating columns are

play02:12

the ones

play02:12

that contain almost same type of

play02:15

information but in different

play02:16

columns the solution for the problem is

play02:19

that

play02:20

we'll take out the part which is which

play02:21

is creating problem in this table which

play02:23

are the phone numbers

play02:24

and create a separate table for phone

play02:26

numbers and

play02:28

connect them with the relevant value

play02:31

which is the name in this case and then

play02:33

join both the tables

play02:35

now it's in first normal form although

play02:37

the tables

play02:38

have increased from 1 to 2 but there is

play02:41

no repeating values or no repeating

play02:43

columns database can easily handle

play02:45

more than one tables but it does not

play02:48

handle repeating values and repeating

play02:50

columns so we'll need to take care of

play02:51

that and now this table is in perfectly

play02:54

first normal form

play02:55

condition the table does not contain any

play02:58

repeating values or repeated columns

play03:00

for a table to be in a second normal

play03:01

form it must have three things in it it

play03:03

should be in first normal form

play03:05

no partial dependency partial dependency

play03:07

only can occur when there is a composite

play03:09

key

play03:10

now what is composite key composite key

play03:12

composite key is when

play03:14

there is more than one primary key

play03:15

column means we just cannot identify

play03:18

the result from one particular column in

play03:21

this example

play03:22

if we only make a primary key of student

play03:25

id

play03:26

we cannot take a record of any student

play03:28

conveniently because

play03:30

what if we say give me the result of two

play03:32

zero one now two zero one

play03:34

we cannot be sure if we are asking for

play03:36

one two zero ones for software

play03:38

architecture result or

play03:39

quality assurance result likewise what

play03:42

if somebody asked

play03:43

us to give a result of 205 205 is

play03:46

enrolled in history and quality software

play03:48

architecture as well so

play03:52

we make another column as a primary key

play03:54

now we can easily judge a record

play03:58

now the question will be give us a

play04:00

result of student id 201

play04:02

in the course quality assurance

play04:06

or give us a result of student id 205

play04:10

in the course of history now student id

play04:12

was already a primary key we have also

play04:14

made course as a primary key

play04:16

as well when there is there are more

play04:18

primary key columns

play04:20

they are combinedly called as composite

play04:21

key now more about partial dependency

play04:24

student id and course are key columns

play04:28

name marks and teacher are non-key

play04:30

columns here in this table

play04:32

now what is partial dependency partial

play04:34

dependency is when

play04:35

any of the non-key column does not

play04:37

depend on all primary key columns

play04:39

like here a teacher only depends on

play04:43

the course what course does a teacher

play04:46

teach

play04:47

it only depends on code it it does not

play04:49

have anything to do with student id

play04:52

both both are key columns here is a

play04:54

classic situation of

play04:55

the fact that non-key column

play04:58

is only partially dependent on on the

play05:01

key columns

play05:02

so this is called partial dependency and

play05:04

then when there is a partial dependency

play05:06

we need to we need to break that that

play05:09

column

play05:10

into another table which is only

play05:12

partially dependent marks and name both

play05:13

are totally dependent on both the keys

play05:15

so no need there

play05:17

teaches column and taken away from the

play05:19

main

play05:20

table and it is it is combined with the

play05:22

course column

play05:24

two tables and both tables does not have

play05:27

any partial dependency

play05:29

so it is now considered in the second

play05:31

normal form

play05:39

for a table to be in a third normal form

play05:41

it must be in a first normal form and

play05:43

second normal form already

play05:45

third normal form should not have a

play05:46

transitive dependency

play05:48

what is transitive dependency we'll see

play05:50

in the example now one more thing to

play05:52

note is that

play05:53

if one non-key column can be guessed

play05:55

from other non-key column

play05:57

that means it is violating third normal

play05:59

forms rule

play06:00

and we need to break the table we can go

play06:03

through the examples to

play06:04

make it more understandable in this

play06:05

table student id is the primary key

play06:08

column and name exam type and maximum

play06:10

marks are non-key columns

play06:11

from the table we can guess that if a

play06:14

student is opting for viva

play06:16

means maximum marks will be 20 student

play06:18

is opting for theory

play06:20

it will be of hundred marks and

play06:22

practical will be of 50 marks

play06:23

means we can guess the maximum marks

play06:25

column from

play06:26

exam type column and it also means that

play06:30

maximum marks column and transitively

play06:32

depending on

play06:32

exam type column so if

play06:36

some student of id 209 comes

play06:39

and he's opting for practical exam we'll

play06:42

already know

play06:43

the maximum marks of practical would be

play06:44

50. this is the classic case of

play06:46

violating third normal form we will

play06:48

break the maximum marks column and put

play06:50

it in

play06:50

the another table now it's not in third

play06:53

normal form

play06:54

there is no transitive dependency

play06:55

between the tables transitive dependency

play06:57

is bit tricky so we'll see another

play06:59

example of that

play07:00

now mesh match number is the primary key

play07:02

teams ground and capacity

play07:04

these are the non-primary keys of this

play07:06

table it is absolutely clear

play07:08

that if the match is played in mcg the

play07:10

capacity of mcg is 80 000.

play07:13

if it's played in hobart it's 30 000.

play07:16

likewise the other ground we already

play07:18

know the capacity of the grounds

play07:20

so if match number 9 is played in mcg

play07:23

will automatically put 80 000 in the

play07:25

capacity column

play07:26

so this is again capacity table is

play07:29

transitively

play07:30

depending on ground table again

play07:32

violating third normal form we'll break

play07:34

the table

play07:34

taking away the transitive part of the

play07:37

table which is capacity

play07:38

putting it in another table last example

play07:41

for the third normal form

play07:42

in this table if someone's designation

play07:45

is manager

play07:46

the salary he'll be getting will be of

play07:48

80 000

play07:49

in the database table if there is any

play07:51

transitive dependency between the

play07:53

non-key columns we'll only break the

play07:55

part that is transitively depending

play07:58

on other part transitive dependency also

play08:00

occurs when there is a kind of

play08:02

calculation performed in the tables like

play08:03

in this table

play08:05

the amount of earning is dependent on

play08:07

total

play08:08

ticket sale multiplied by the price of

play08:11

the ticket

play08:12

this is also a transitive dependency if

play08:15

there are a thousand tickets sold and

play08:16

each ticket is of 200 then there is a

play08:18

earning of 200 000 so if any calculation

play08:21

can be performed on table

play08:23

it is also considered in third normal

play08:25

form

Rate This

5.0 / 5 (0 votes)

الوسوم ذات الصلة
Database DesignNormalization RulesData RedundancyTable StructuresData SecurityFirst Normal FormSecond Normal FormThird Normal FormComposite KeyPartial Dependency
هل تحتاج إلى تلخيص باللغة الإنجليزية؟