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:
ID | Name | Age | Contact |
---|---|---|---|
1 | Ramesh | 32 | 1234567890,21314152 |
2 | Mukesh | 40 | 8978654372 |
3 | Sumit | 45 | 9450012002 |
4 | Kaushik | 25 | 8912342503 |
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
ID | Contact |
---|---|
1 | 1234567890 |
1 | 21314152 |
2 | 8978654372 |
3 | 9450012002 |
4 | 8912342503 |
ID | Name | Age | City1 | City2 | Country |
---|---|---|---|---|---|
1 | Ramesh | 32 | Hyderabad | Delhi | India |
2 | Mukesh | 40 | New York | USA | |
3 | Sumit | 45 | Muscat | Oman | |
4 | Kaushik | 25 | Kolkata | India |
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:
ID | Name | Age |
---|---|---|
1 | Ramesh | 32 |
2 | Mukesh | 40 |
3 | Sumit | 45 |
4 | Kaushik | 25 |
ID | City | Country |
---|---|---|
1 | Hyderabad | India |
1 | Delhi | India |
2 | New York | USA |
3 | Muscat | Oman |
4 | Kolkata | India |
Note: also read about Normalization of Database
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
Staying up to the mark is what defines me. Hi all! I’m Rabecca Fatima a keen learner, great enthusiast, ready to take new challenges as stepping stones towards flying colors.
Problem Statement: Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. Example…
Given an integer A. Compute and return the square root of A. If A is…
Given a zero-based permutation nums (0-indexed), build an array ans of the same length where…
A heap is a specialized tree-based data structure that satisfies the heap property. It is…
What is the Lowest Common Ancestor? In a tree, the lowest common ancestor (LCA) of…