Categories: DBMS

First Normal Form (1NF)

Let’s look at the first normal form in detail from the previous lecture where we saw a brief overview of the normal forms.

First Normal Form (1NF) is the first level of normalization in database design. It ensures that the data in a table is organized in a way that avoids redundancy and anomalies. The two rules of 1NF are:

  • Atomic Values: Only atomic or indivisible values should be present in each column. For instance, the 1NF is violated when a column that stores a list of phone numbers separated by commas has multiple values.
  • No Repeating Groups: Only one value should be present in each column. No repeating data sets or multiple values in the same column are acceptable. For example, a column that stores multiple addresses for a single customer violates 1NF because it contains repeating groups of data.
Example: Atomic Value Violation
IDNameAgeContact
1Ramesh321234567890,21314152
2Mukesh408978654372
3Sumit459450012002
4Kaushik258912342503
Customer Table

The above table violates the 1NF rule as the contact value for first row isn’t atomic. To solve such an issue we will create another table, i.e

IDContact
11234567890
121314152
28978654372
39450012002
48912342503
Contact Table
Example: Repeating Groups
IDNameAgeCity1City2Country
1Ramesh32HyderabadDelhiIndia
2Mukesh40New YorkUSA
3Sumit45MuscatOman
4Kaushik25KolkataIndia
Customer Table

Because the City column is repeated twice, this table is not in the first normal form, as you can see in the current table. Whether the person stays in two cities or not, this table always allots disc space for two cities.

To eliminate the repeating columns and bring the table to the first normal form, separate the table into two tables. Create one of the tables with the repeating columns as shown below:

IDNameAge
1Ramesh32
2Mukesh40
3Sumit45
4Kaushik25
Customer Table
IDCityCountry
1HyderabadIndia
1DelhiIndia
2New YorkUSA
3MuscatOman
4KolkataIndia
Address Table

Note: also read about Normalization of Database

Follow Me

Please follow me to read my latest post on programming and technology if you like my post.

https://www.instagram.com/coderz.py/

https://www.facebook.com/coderz.py

Share
Published by
Rabecca Fatima

Recent Posts

Generate Parenthesis | Intuition + Code | Recursion Tree | Backtracking | Java

Problem Statement: Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. Example…

2 months ago

Square Root of Integer

Given an integer A. Compute and return the square root of A. If A is…

1 year ago

Build Array From Permutation

Given a zero-based permutation nums (0-indexed), build an array ans of the same length where…

1 year ago

DSA: Heap

A heap is a specialized tree-based data structure that satisfies the heap property. It is…

1 year ago

DSA: Trie

What is a Trie in DSA? A trie, often known as a prefix tree, is…

1 year ago

Trees: Lowest Common Ancestor

What is the Lowest Common Ancestor? In a tree, the lowest common ancestor (LCA) of…

1 year ago