1. Home
  2. Articles
  3. Courses
    1. Articles
  4. Community
  5. Definitions
  6. Files
    1. Terms Of Condition
  • Login
  • Register
  • Search
Course Articles
  • Everywhere
  • Articles
  • Pages
  • Forum
  • Definitions
  • Course Articles
  • Filebase Entry
  • More Options
  1. Scientific Tools
  2. Courses
  3. MySQL Guides

What is Normal Forms and Normalization in MySQL

  • ScientificTools.org
  • November 28, 2023 at 2:38 PM
  • 1,385 times read
Contents [hideshow]
  1. What is Normalization?
  2. First Normal Form (1NF)
    1. Example: Converting a Table to 1NF
  3. Second Normal Form (2NF)
    1. Example: Converting a Table to 2NF
  4. Third Normal Form (3NF)
    1. Example: Converting a Table to 3NF

Normalization in MySQL is a process of structuring a relational database to minimize redundancy and improve data integrity. This guide introduces you to the concept of normalization and how it is applied in MySQL.

What is Normalization?

Normalization involves organizing data in a database into tables and columns in a way that reduces redundancy and dependency. It involves dividing large tables into smaller, interrelated tables and defining relationships between them.

First Normal Form (1NF)

The First Normal Form requires that each table cell should contain a single value, and each record needs to be unique.

Example: Converting a Table to 1NF

Suppose we have an Orders table that violates 1NF because it contains multiple values in the Items column.

Before 1NF:

OrderID Items
1 Pen, Notebook, Eraser
2 Pencil, Eraser

To convert this table to 1NF, we need to ensure that each field contains only atomic (indivisible) values.


After 1NF:

SQL
CREATE TABLE Orders (    OrderID INT,    Item VARCHAR(100)
);

INSERT INTO Orders (OrderID, Item) VALUES
(1, 'Pen'),
(1, 'Notebook'),
(1, 'Eraser'),
(2, 'Pencil'),
(2, 'Eraser');

Each Item is now in its own row, adhering to 1NF.

Second Normal Form (2NF)

A table is in 2NF if it is in 1NF and all non-key columns are fully dependent on the primary key

Example: Converting a Table to 2NF

Let's consider a StudentCourses table that is in 1NF but not in 2NF due to partial dependency.

Before 2NF:

StudentID Course Instructor
101 Math Dr. Smith
101 Science Dr. Jones
102 Math Dr. Smith

The Instructor is dependent only on the Course, not on the composite key (StudentID, Course).

After 2NF:

SQL
CREATE TABLE StudentCourses (    StudentID INT,    Course VARCHAR(100)
);

CREATE TABLE Courses (    Course VARCHAR(100),    Instructor VARCHAR(100)
);

INSERT INTO StudentCourses (StudentID, Course) VALUES
(101, 'Math'),
(101, 'Science'),
(102, 'Math');

INSERT INTO Courses (Course, Instructor) VALUES
('Math', 'Dr. Smith'),
('Science', 'Dr. Jones');
Display More

The Courses table is created to remove the partial dependency, achieving 2NF.

Third Normal Form (3NF)

Example: Converting a Table to 3NF

Consider a Customers table in 2NF but not in 3NF due to transitive dependency.

Before 3NF:

CustomerID Address ZipCode City Country
001 123 Lane 90001 Los Angeles USA
002 456 Avenue 10001 New York USA

The City and Country are transitively dependent on CustomerID through ZipCode.


After 3NF:

SQL
CREATE TABLE Customers (    CustomerID INT AUTO_INCREMENT PRIMARY KEY,    Address VARCHAR(255),    ZipCode INT
);

CREATE TABLE ZipCodes (    ZipCode INT PRIMARY KEY,    City VARCHAR(100),    Country VARCHAR(100)
);

INSERT INTO Customers (CustomerID, Address, ZipCode) VALUES
(001, '123 Lane', 90001),
(002, '456 Avenue', 10001);

INSERT INTO ZipCodes (ZipCode, City, Country) VALUES
(90001, 'Los Angeles', 'USA'),
(10001, 'New York', 'USA');
Display More

The ZipCodes table is created to remove the transitive dependency, adhering to 3NF.

  • Previous Article How to design a MySQL database with high performance
  • Next Article Guide to Entity-Relationship (ER) Diagrams in MySQL with Examples

Categories

  • MySQL

Archive

  1. 2023 (33)
    1. November (27)
      • Guide to MySQL IN and NOT IN Operators
      • Guide to MySQL OR Operator
      • Guide to MySQL AND Operator
      • Guide to MySQL DISTINCT Clause
      • MySQL SELECT FROM Statement Guide
      • What is EXPLAIN statement in MySQL and what it does ?
      • Guide to Query Caching in MySQL
      • How to Optimize MySQL Queries?
      • Guide to Entity-Relationship (ER) Diagrams in MySQL with Examples
      • What is Normal Forms and Normalization in MySQL
      • How to design a MySQL database with high performance
      • Principals of Secure Database Design in MySQL
      • How to secure and harden MySQL
      • User Management MySQL: Guide to Create, Manage and Permissions
      • Guide to Views in MySQL: Creating Updating Deleting
      • Guide to Stored Procedures and Functions in MySQL
      • Guide to Indexes in MySQL: Creating and Managing Indexes
      • Advanced Filtering in MySQL guide and examples
      • Practical guide for UNION and UNION ALL in MySQL with examples
      • Joining Tables in MySQL guide with examples
      • Guide to GROUP BY and HAVING clauses in MySQL with examples
      • MySQL ORDER BY Clause guide with practical examples
      • Complete MySQL WHERE Clause guide with examples
      • What is a MySQL subquery and how are subqueries executed in MySQL?
      • How to do queries in MySQL
      • How to create, modify, rename and delete tables using MySQL
      • MySQL CRUD Operations (Create, Read, Update, Delete)
    2. October (2)
    3. August (2)
    4. July (2)
  1. Privacy Policy
  2. Legal Notice
Copyright© ScientificTools.org 2026. All rights reserved.
All the content posted on this website are licenses by MySecure Space GmbH under Creative Commons CC BY-NC-ND 4.0
Creative Commons CC BY-NC-ND 4.0
Developed & Hosted by: MySecure.Space | Powered by: WoltLab Suite™