Violation Of 1NF and how to deal with it
What is 1 NF?
The first normal form (1NF) is one of the most violated rules while designing and developing a database.The First normal form (1NF) is a property of a relation in a relational database. A relation is in first normal form if and only if the domain of each attribute contains only atomic (indivisible) values, and the value of each attribute contains only a single value from that domain.
The benefits of Normalization are:
- Greater overall database organization
- Reduction of redundant data
- Data consistency within the database
- A much more flexible database design
- A better handle on database security
In simpler terms, A column must contain a single value and not multiple values separated by a delimiter of the designer’s choice.
Id | City | State |
1 | Bangalore | Karnataka |
2 | Mumbai; Delhi | Maharastra; New Delhi |
From the above sample table, the first record shows it is a valid record as per 1NF, whereas, the 2nd record is in violation of the rule as it consists of multiple values with a delimiter.
Most often, we come across systems designed that has violated this rule. The most common reason given for violating the rule is that space required to store data is minimum and at times remove redundancy as well. Given the fact that many systems use such a technique, a database developer has to know the workarounds with such a design.
With some experience working on the SQL Server, splitting the column values to bring to a tabular form is my preferred way of dealing with such a system.
The Split Function:
It is always advisable to utilize the Normalization techniques while designing a database, which makes the queries perform better. As mentioned above, if you have to deal with a legacy system or a system designed by a developer before you, this would be one of the methods to get your job done.
Backend developer, Works on C#, SQL server lives in Manipal, Karnataka, India.