Normalization and Denormalization in Databases

Thirdy GayaresThirdy Gayares
6 min read

What is Normalization? Normalization is a method used in organizing data inside a database. It breaks down big tables into smaller, simpler tables and links them. This method helps avoid duplicate data and ensures that all data is stored clearly and logically. By doing this, databases can work better because they don't have unnecessary or repeated information.

Benefits of Normalization:

  • Clearer Data: Data is organized more clearly, which helps in managing and using the data effectively.

  • Avoids Problems: Reduces problems like data being wrong or missing when you add, delete, or change data.

  • Saves Space: It uses the storage space more efficiently.

What is Denormalization? Denormalization is a technique used to speed up how fast you can get data from a database. It does this by allowing some duplicate data. By combining tables and adding duplicate data, databases can find information faster, which is useful when you need to get a lot of data quickly.

Benefits of Denormalization:

  • Faster Data Access: This helps you get data faster, which is useful for reports or analysis that need quick access to large amounts of information.

  • Simpler Queries: This makes writing database queries simpler because data that needs to be accessed together is kept together.

When to Use Each:

  • Normalization is usually better when you need to make sure your data is very accurate and stored efficiently, like in systems where data is constantly being added or changed.

  • Denormalization might be better in situations where you need to read data a lot and fast, like in systems that generate reports or handle lots of searches.

Example

Denormalized "Students" Table Structure

StudentIDNameEmailPasswordSectionSubjectsProfessorsGWAIsActiveLsEnrolledIsSuspendedAddressPhoneBirthDateEmergencyContactRegistrationDateAdvisorName
1John Doejohndoe@example.compass1234A1Math, ScienceDr. Smith, Prof. Lee3.5true2023-08false123 Elm St123-456-78902000-01-01123-456-78912020-08-01Dr. Allen
2Jane Smithjanes@example.compass5678A2English, HistoryProf. Kent, Dr. Jones3.7true2023-08false456 Maple Ave234-567-89011999-02-15234-567-89022019-09-01Prof. Carter
3Alice Johnsonalicej@example.compass91011A1Science, PEDr. Smith, Coach Ray3.8false2023-08true789 Oak Blvd345-678-90122001-03-30345-678-90132021-01-15Dr. Harris
4Bob Brownbobb@example.compass1213A2Math, EnglishDr. Lee, Prof. Kent3.2true2023-08false321 Pine Rd456-789-01232000-05-25456-789-01242022-07-10Prof. Sanders
5Carol Whitecarolw@example.compass1415A1History, ScienceDr. Jones, Dr. Smith3.9true2023-08false654 Spruce Ln567-890-12341998-07-09567-890-12352018-08-20Dr. Murphy
6Dave Greendaveg@example.compass1617A2PE, MathCoach Ray, Dr. Lee2.9false2023-08true987 Cedar St678-901-23452002-09-17678-901-23462023-01-05Prof. Thompson
7Eva Blackevab@example.compass1819A1English, PEProf. Kent, Coach Ray3.6true2023-08false321 Birch St789-012-34562001-11-23789-012-34572022-06-15Dr. Allen
8Frank Grayfrankg@example.compass2021A2History, MathDr. Jones, Dr. Lee3.1true2023-08false213 Willow Rd890-123-45671997-12-31890-123-45682017-09-25Prof. Carter
9Grace Hillgraceh@example.compass2223A1Science, HistoryDr. Smith, Dr. Jones4.0false2023-08true132 Elm St901-234-56782002-02-20901-234-56792021-10-30Dr. Harris
10Henry Lakehenryl@example.compass2425A2English, PEProf. Kent, Coach Ray2.8true2023-08false312 Maple Ave012-345-67891999-04-05012-345-67902019-12-05Prof. Sanders

Normalization Table Structure

1. Students Table

StudentIDNameEmailPasswordBirthDateIsActiveLsEnrolledIsSuspended
1John Doejohndoe@example.compass12342000-01-01true2023-08false
2Jane Smithjanes@example.compass56781999-02-15true2023-08false
........................

2. Address Table

AddressIDStudentIDAddressPhoneEmergencyContact
11123 Elm St123-456-7890123-456-7891
22456 Maple Ave234-567-8901234-567-8902
...............

3. Subjects Table

SubjectIDName
1Math
2Science
......
  1. Enrollments Table

5. Professors Table

ProfessorIDName
1Dr. Smith
2Prof. Lee
......

6. Advisors Table

Stores advisor information and links them to students.

AdvisorIDProfessorID
11
22
......

7. Registrations Table

RegistrationIDStudentIDRegistrationDateAdvisorID
112020-08-011
222019-09-012
............

Normalization Benefits:

  • Reduces Redundancy: Each piece of information exists only once in the database.

  • Improves Data Integrity: Updates have to be made in only one place, reducing the risk of inconsistent data.

  • Enhances Security: Can apply security measures to individual tables. For example, limiting access to the password table.

This normalized model minimizes redundancy by ensuring that each data element is stored only once. Relationships among the data are maintained through foreign keys

References:

GeeksforGeeks.

Difference between Normalization and Denormalization (tutorialspoint.com)

Normalization in SQL (1NF - 5NF): A Beginner’s Guide | DataCamp

0
Subscribe to my newsletter

Read articles from Thirdy Gayares directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Thirdy Gayares
Thirdy Gayares

I am a dedicated and skilled Software Engineer specializing in mobile app development, backend systems, and creating secure APIs. With extensive experience in both SQL and NoSQL databases, I have a proven track record of delivering robust and scalable solutions. Key Expertise: Mobile App Development: I make high-quality apps for Android and iOS, ensuring they are easy to use and work well. Backend Development: Skilled in designing and implementing backend systems using various frameworks and languages to support web and mobile applications. Secure API Creation: Expertise in creating secure APIs, ensuring data integrity and protection across platforms. Database Management: Experienced with SQL databases such as MySQL, and NoSQL databases like Firebase, managing data effectively and efficiently. Technical Skills: Programming Languages: Java, Dart, Python, JavaScript, Kotlin, PHP Frameworks: Angular, CodeIgniter, Flutter, Flask, Django Database Systems: MySQL, Firebase Cloud Platforms: AWS, Google Cloud Console I love learning new things and taking on new challenges. I am always eager to work on projects that make a difference.