0% found this document useful (0 votes)
44 views

Normalization: Mrs. CH - Swathi

The document discusses database normalization which is a process of organizing data to minimize redundancy and dependency. It involves decomposing tables to satisfy certain normal forms like 1NF, 2NF, 3NF and BCNF. The normal forms impose rules to reduce anomalies and ensure data integrity. For example, 1NF requires each cell contain a single value, 2NF eliminates partial dependencies, and 3NF removes transitive dependencies for non-prime attributes. Normalization helps standardize database structure for efficiency and correctness.

Uploaded by

shaista firdouse
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views

Normalization: Mrs. CH - Swathi

The document discusses database normalization which is a process of organizing data to minimize redundancy and dependency. It involves decomposing tables to satisfy certain normal forms like 1NF, 2NF, 3NF and BCNF. The normal forms impose rules to reduce anomalies and ensure data integrity. For example, 1NF requires each cell contain a single value, 2NF eliminates partial dependencies, and 3NF removes transitive dependencies for non-prime attributes. Normalization helps standardize database structure for efficiency and correctness.

Uploaded by

shaista firdouse
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 24

Normalization

Mrs. Ch.Swathi
• Normalization in DBMS
In DBMS, database normalization is a process of making the database consistent by-

• Reducing the redundancies


• Ensuring the integrity of data through lossless decomposition

Normalization is done through normal forms.


Normal Forms-

3
1. First Normal Form (1NF)
A given relation is called in First Normal Form (1NF) if each cell of the table contains only an atomic value.
OR
A given relation is called in First Normal Form (1NF) if the attribute of every tuple is either single valued or a null
value.

Example
The following relation is not in 1NF-

Student_id Name Subjects

100 Akshay Computer Networks, Designing

101 Aman Database Management System

102 Anjali Automata, Compiler Design


However,

• This relation can be brought into 1NF.

• This can be done by rewriting the relation such that each cell of the table contains only one value.

Student_id Name Subjects

100 Akshay Computer Networks

100 Akshay Designing

101 Aman Database Management System


102 Anjali Automata

102 Anjali Compiler Design

This relation is in First Normal Form (1NF).

NOTE
• By default, every relation is in 1NF.
• This is because formal definition of a relation states that value of all the attributes must be atomic.
2 . Second Normal Form (2NF)
A given relation is called in Second Normal Form (2NF) if and only if -

1. Relation already exists in 1NF.


2. No partial dependency exists in the relation.

Example-
Consider a relation- R ( V , W , X , Y , Z ) with functional dependencies-

VW → XY
Y→V
WX → YZ

The possible candidate keys for this relation are-

VW , WX , WY
From here,

• Prime attributes = { V , W , X , Y }
• Non-prime attributes = { Z }

Now, if we observe the given dependencies-

• There is no partial dependency.

• This is because there exists no dependency where incomplete candidate key determines any non-
prime attribute.

Thus, we conclude that the given relation is in 2NF.


Partial Dependency

A partial dependency is a dependency where few attributes of the candidate key determines non-prime
attribute(s).
OR
A partial dependency is a dependency where a portion of the candidate key or incomplete candidate key
determines non-prime attribute(s).

In other words,

A → B is called a partial dependency if and only if-

1.A is a subset of some candidate key


2.B is a non-prime attribute.
If any one condition fails, then it will not be a partial dependency.

NOTE-

• To avoid partial dependency, incomplete candidate key must not determine any non-prime attribute.

• However, incomplete candidate key can determine prime attributes.


3. Third Normal Form (3NF)

A given relation is called in Third Normal Form (3NF) if and only if-

1.Relation already exists in 2NF.


2.No transitive dependency exists for non-prime attributes.

Transitive Dependency

A → B is called a transitive dependency if and only if-


1.A is not a super key.
2.B is a non-prime attribute.
If any one condition fails, then it is not a transitive dependency.

NOTE-

•Transitive dependency must not exist for non-prime attributes.


•However, transitive dependency can exist for prime attributes.
OR

A relation is called in Third Normal Form (3NF) if and only if-


Any one condition holds for each non-trivial functional dependency A → B
1.A is a super key
2.B is a prime attribute

Example-

Consider a relation- R ( A , B , C , D , E ) with functional dependencies-


A → BC
CD → E
B→D
E→A

The possible candidate keys for this relation are-


A , E , CD , BC
From here,

• Prime attributes = { A , B , C , D , E }
• There are no non-prime attributes

Now,

• It is clear that there are no non-prime attributes in the relation.


• In other words, all the attributes of relation are prime attributes.
• Thus, all the attributes on RHS of each functional dependency are prime attributes.

Thus, we conclude that the given relation is in 3NF.


4. Boyce-Codd Normal Form (BCNF)
A given relation is called in BCNF if and only if-

1. Relation already exists in 3NF.


2. For each non-trivial functional dependency A → B, A is a super key of the relation.

Example-
Consider a relation- R ( A , B , C ) with the functional dependencies-
A→B
B→C
C→A
The possible candidate keys for this relation are- A , B , C

Now, we can observe that RHS of each given functional dependency is a candidate key.

Thus, we conclude that the given relation is in BCNF.


Normal Form Description

1NF A relation is in 1NF if it contains an atomic value.

2NF A relation will be in 2NF if it is in 1NF and all non-key


attributes are fully functional dependent on the primary key.

3NF A relation will be in 3NF if it is in 2NF and no transition


dependency exists.

4NF A relation will be in 4NF if it is in Boyce Codd normal form


and has no multi-valued dependency.

5NF A relation is in 5NF if it is in 4NF and not contains any join


dependency and joining should be lossless.
Keys in DBMS
Different Types Of Keys in DBMS

There are following 10 important keys in DBMS-


1. Super Key-
• A super key is a set of attributes that can identify each tuple uniquely in the given relation.
• A super key is not restricted to have any specific number of attributes.
• Thus, a super key may consist of any number of attributes.
Example-

Consider the following Student schema


Student ( roll , name , gender , age , address , class , section )

Given below are the examples of super keys since each set can uniquely identify each student in the
Student table-
• ( roll , name , gender , age , address , class , section )
• ( class , section , roll )
• (class , section , roll , gender )
• ( name , address )

NOTE

All the attributes in a super key are definitely sufficient to identify each tuple uniquely in the given relation but
all of them may not be necessary.
2. Candidate Key-
A minimal super key is called as a candidate key.
OR
A set of minimal attribute(s) that can identify each tuple uniquely in the given relation is called as a candidate
key.
Example-

Consider the following Student schema-


Student ( roll , name , sex , age , address , class , section )
Given below are the examples of candidate keys since each set consists of minimal attributes required to identify each
student uniquely in the Student table-
• ( class , section , roll )
• ( name , address )

NOTES-
• All the attributes in a candidate key are sufficient as well as necessary to identify each tuple uniquely.
• Removing any attribute from the candidate key fails in identifying each tuple uniquely.
• The value of candidate key must always be unique.
• The value of candidate key can never be NULL.
• It is possible to have multiple candidate keys in a relation.
• Those attributes which appears in some candidate key are called as prime attributes.
3. Primary Key-

A primary key is a candidate key that the database designer selects while designing the database.
OR
Candidate key that the database designer implements is called as a primary key.
NOTES-

•The value of primary key can never be NULL.


•The value of primary key must always be unique.
•The values of primary key can never be changed i.e. no updation is possible.
•The value of primary key must be assigned when inserting a record.
•A relation is allowed to have only one primary key.
4. Alternate Key-

Candidate keys that are left unimplemented or unused after implementing the primary key are called as alternate keys.
OR
Unimplemented candidate keys are called as alternate keys.

5. Foreign Key-

•An attribute ‘X’ is called as a foreign key to some other attribute ‘Y’ when its values are dependent on the
values of attribute ‘Y’.
•The attribute ‘X’ can assume only those values which are assumed by the attribute ‘Y’.
•Here, the relation in which attribute ‘Y’ is present is called as the referenced relation.
•The relation in which attribute ‘X’ is present is called as the referencing relation.
•The attribute ‘Y’ might be present in the same table or in some other table.
Example-

Consider the following two schemas-

Here, t_dept can take only those values which are present in dept_no in Department table since only those departments
actually exist.
NOTES-

•Foreign key references the primary key of the table.


•Foreign key can take only those values which are present in the primary key of the referenced relation.
•Foreign key may have a name other than that of a primary key.
•Foreign key can take the NULL value.
•There is no restriction on a foreign key to be unique.
•In fact, foreign key is not unique most of the time.
•Referenced relation may also be called as the master table or primary table.
•Referencing relation may also be called as the foreign table.

6. Partial Key-

•Partial key is a key using which all the records of the table can not be identified uniquely.
•However, a bunch of related tuples can be selected from the table using the partial key.
Example-

Consider the following schema-


Department ( Emp_no , Dependent_name , Relation )

Emp_no Dependent_name Relation

E1 Suman Mother

E1 Ajay Father

E2 Vijay Father
Son
E2 Ankush

Here, using partial key Emp_no, we can not identify a tuple uniquely but we can select a bunch of tuples
from the table.
7. Composite Key-

A primary key comprising of multiple attributes and not just a single attribute is called as a composite key.

8. Unique Key-

Unique key is a key with the following properties-


•It is unique for all the records of the table.
•Once assigned, its value can not be changed i.e. it is non-updatable.
•It may have a NULL value.

Example-

The best example of unique key is Adhaar Card Numbers.


•The Adhaar Card Number is unique for all the citizens (tuples) of India (table).
•If it gets lost and another duplicate copy is issued, then the duplicate copy always has the same number as before.
•Thus, it is non-updatable.
•Few citizens may not have got their Adhaar cards, so for them its value is NULL.
9. Surrogate Key-

Surrogate key is a key with the following properties-


•It is unique for all the records of the table.
•It is updatable.
•It can not be NULL i.e. it must have some value.

Example-

Mobile Number of students in a class where every student owns a mobile phone.

10. Secondary Key-

Secondary key is required for the indexing purpose for better and faster searching.

You might also like