What is Database Normalization?Explain the guidelines for ensuring that database are
normalized.
Solution
Here is the answer for your respective question on database normalization:
Before going to know about database normalization we should know about database.
So what is a database?
Its like a repository where all the data related to a particular organization are stored inside the
tables in the form of columns and rows
which can be related to the employees working in that organization or about the finacial and
accounts of the company etc.
While storing data into the tables there might be some problems like duplicate entries of the
same record related to a particular person which creates a problem named data redundancy in the
database.
So to avoid this there\'s been introduced a concept named Normalization.
So what is Database Normalization?
Database normalization or simply called normalization, is the process of arranging or organizing
the columns
and tables of a relational database to reduce data redundancy and improve data integrity and
efficiency of data stored.
Normalization arranges attributes in tables based on dependencies between attributes,
ensuring that the dependencies are properly enforced by database integrity constraints.
Normalization can be achieved by applying some formal rules like synthesis or decomposition.
To come to the types of normalizations there are many.Some of them are as follows:
1NF - First Normal Form
2NF - Second Normal Form
3NF - Third Normal Form
BCNF - Boyce–Codd Normal Form
4NF - Fourth Normal Form
Basic guidelines for normalization:
1NF - First Normal Form:
As per First Normal Form, no two Rows of data must contain repeating group of information.
Each table should be organized into rows and each row should have a primary key that
distinguishes it as unique.
Example for 1NF:
Student Age Subject
Andrea 15 Zoology
Andrea 15 Social Studies
Alan 14 Maths
Stuart 17 Maths
But by using the First Normal Form, data redundancy increases,
as there will be many columns with same data in multiple rows but each row as a whole will be
unique.
2NF - Second Normal Form:
There must not be any partial dependency of any column on primary key.
Meaning that for a table that has concatenated primary key, each column in the table
that is not part of the primary key must depend upon the entire concatenated key for its
existence,failing which the table fails Second normal form.
Example:
Student Age
Andrea 15
Alex 14
Stuart 17
Here we should maintain a separate table for the value subject by doing which we can reduce
data redundancy which is lacking in 1NF.
In the above table,candidate key will be Student column, because all other column i.e Age is
dependent on it.
3NF - Third Normal Form:
Third normal form (3NF) is a database principle that allows you to properly
arrange our tables by building upon the database normalization principles provided by 1NF and
2NF.
There are two basic requirements for a database to be in third normal fo.
What is Database NormalizationExplain the guidelines for ensuring t.pdf
1. What is Database Normalization?Explain the guidelines for ensuring that database are
normalized.
Solution
Here is the answer for your respective question on database normalization:
Before going to know about database normalization we should know about database.
So what is a database?
Its like a repository where all the data related to a particular organization are stored inside the
tables in the form of columns and rows
which can be related to the employees working in that organization or about the finacial and
accounts of the company etc.
While storing data into the tables there might be some problems like duplicate entries of the
same record related to a particular person which creates a problem named data redundancy in the
database.
So to avoid this there's been introduced a concept named Normalization.
So what is Database Normalization?
Database normalization or simply called normalization, is the process of arranging or organizing
the columns
and tables of a relational database to reduce data redundancy and improve data integrity and
efficiency of data stored.
Normalization arranges attributes in tables based on dependencies between attributes,
ensuring that the dependencies are properly enforced by database integrity constraints.
Normalization can be achieved by applying some formal rules like synthesis or decomposition.
To come to the types of normalizations there are many.Some of them are as follows:
1NF - First Normal Form
2NF - Second Normal Form
3NF - Third Normal Form
BCNF - Boyce–Codd Normal Form
4NF - Fourth Normal Form
Basic guidelines for normalization:
1NF - First Normal Form:
As per First Normal Form, no two Rows of data must contain repeating group of information.
Each table should be organized into rows and each row should have a primary key that
distinguishes it as unique.
2. Example for 1NF:
Student Age Subject
Andrea 15 Zoology
Andrea 15 Social Studies
Alan 14 Maths
Stuart 17 Maths
But by using the First Normal Form, data redundancy increases,
as there will be many columns with same data in multiple rows but each row as a whole will be
unique.
2NF - Second Normal Form:
There must not be any partial dependency of any column on primary key.
Meaning that for a table that has concatenated primary key, each column in the table
that is not part of the primary key must depend upon the entire concatenated key for its
existence,failing which the table fails Second normal form.
Example:
Student Age
Andrea 15
Alex 14
Stuart 17
Here we should maintain a separate table for the value subject by doing which we can reduce
data redundancy which is lacking in 1NF.
In the above table,candidate key will be Student column, because all other column i.e Age is
dependent on it.
3NF - Third Normal Form:
Third normal form (3NF) is a database principle that allows you to properly
arrange our tables by building upon the database normalization principles provided by 1NF and
2NF.
There are two basic requirements for a database to be in third normal form:
It should meet the requirements of both 1NF and 2NF
Should remove columns that are not fully dependent upon the primary key.
For example, in the below table, street name, city, and state are unbreakably bound to the zip
code.
CREATE TABLE EMPLOYEE(
EMP_ID INT NOT NULL,
EMP_NAME VARCHAR (20) NOT NULL,
STREET VARCHAR(200),
3. CITY VARCHAR(100),
STATE VARCHAR(100),
ZIP VARCHAR(12),
PRIMARY KEY (EMP_ID)
);
The dependency between zip code and address in the above shown query is called a transitive
dependency.
To change it to third normal form(3NF), all we need to do is move the Street, City, and State
fields into their own table.
CREATE TABLE ADDRESS(
ZIP VARCHAR(12),
STREET VARCHAR(200),
CITY VARCHAR(100),
STATE VARCHAR(100),
PRIMARY KEY (ZIP)
);
Next, alter the EMPLOYEE table as follows:
CREATE TABLE EMPLOYEE(
EMP_ID INT NOT NULL,
EMP_NAME VARCHAR (20) NOT NULL,
ZIP VARCHAR(12),
PRIMARY KEY (EMP_ID)
);
The advantage of removing transitive dependency is,
1.Amount of data duplication is reduced.
2.Data integrity achieved.
BCNF - Boyce–Codd Normal Form:
This form deals with certain type of anamolies that are not handled by 3NF.
A 3NF table which does not have multiple overlapping candidate keys is said 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.
4NF - Fourth Normal Form :
It should meet all the requirements of 3NF
Attribute of one or more rows in the
table should not result in more than one rows of the same table leading to multi-valued
4. dependencies.
Here is the answer for your respective question on database normalization:
Before going to know about database normalization we should know about database.
So what is a database?
Its like a repository where all the data related to a particular organization are stored inside the
tables in the form of columns and rows
which can be related to the employees working in that organization or about the finacial and
accounts of the company etc.
While storing data into the tables there might be some problems like duplicate entries of the
same record related to a particular person which creates a problem named data redundancy in the
database.
So to avoid this there's been introduced a concept named Normalization.
So what is Database Normalization?
Database normalization or simply called normalization, is the process of arranging or organizing
the columns
and tables of a relational database to reduce data redundancy and improve data integrity and
efficiency of data stored.
Normalization arranges attributes in tables based on dependencies between attributes,
ensuring that the dependencies are properly enforced by database integrity constraints.
Normalization can be achieved by applying some formal rules like synthesis or decomposition.
To come to the types of normalizations there are many.Some of them are as follows:
1NF - First Normal Form
2NF - Second Normal Form
3NF - Third Normal Form
BCNF - Boyce–Codd Normal Form
4NF - Fourth Normal Form
Basic guidelines for normalization:
1NF - First Normal Form:
As per First Normal Form, no two Rows of data must contain repeating group of information.
Each table should be organized into rows and each row should have a primary key that
distinguishes it as unique.
Example for 1NF:
Student Age Subject
Andrea 15 Zoology
Andrea 15 Social Studies
Alan 14 Maths
5. Stuart 17 Maths
But by using the First Normal Form, data redundancy increases,
as there will be many columns with same data in multiple rows but each row as a whole will be
unique.
2NF - Second Normal Form:
There must not be any partial dependency of any column on primary key.
Meaning that for a table that has concatenated primary key, each column in the table
that is not part of the primary key must depend upon the entire concatenated key for its
existence,failing which the table fails Second normal form.
Example:
Student Age
Andrea 15
Alex 14
Stuart 17
Here we should maintain a separate table for the value subject by doing which we can reduce
data redundancy which is lacking in 1NF.
In the above table,candidate key will be Student column, because all other column i.e Age is
dependent on it.
3NF - Third Normal Form:
Third normal form (3NF) is a database principle that allows you to properly
arrange our tables by building upon the database normalization principles provided by 1NF and
2NF.
There are two basic requirements for a database to be in third normal form:
It should meet the requirements of both 1NF and 2NF
Should remove columns that are not fully dependent upon the primary key.
For example, in the below table, street name, city, and state are unbreakably bound to the zip
code.
CREATE TABLE EMPLOYEE(
EMP_ID INT NOT NULL,
EMP_NAME VARCHAR (20) NOT NULL,
STREET VARCHAR(200),
CITY VARCHAR(100),
STATE VARCHAR(100),
ZIP VARCHAR(12),
PRIMARY KEY (EMP_ID)
);
6. The dependency between zip code and address in the above shown query is called a transitive
dependency.
To change it to third normal form(3NF), all we need to do is move the Street, City, and State
fields into their own table.
CREATE TABLE ADDRESS(
ZIP VARCHAR(12),
STREET VARCHAR(200),
CITY VARCHAR(100),
STATE VARCHAR(100),
PRIMARY KEY (ZIP)
);
Next, alter the EMPLOYEE table as follows:
CREATE TABLE EMPLOYEE(
EMP_ID INT NOT NULL,
EMP_NAME VARCHAR (20) NOT NULL,
ZIP VARCHAR(12),
PRIMARY KEY (EMP_ID)
);
The advantage of removing transitive dependency is,
1.Amount of data duplication is reduced.
2.Data integrity achieved.
BCNF - Boyce–Codd Normal Form:
This form deals with certain type of anamolies that are not handled by 3NF.
A 3NF table which does not have multiple overlapping candidate keys is said 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.
4NF - Fourth Normal Form :
It should meet all the requirements of 3NF
Attribute of one or more rows in the
table should not result in more than one rows of the same table leading to multi-valued
dependencies.