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
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 |
Example: Repeating Groups
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
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
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.
Leave a Comment