First normal form(1NF)
- The 1st Normal form expects you to design your table in such a way that it can easily be extended and it is easier for you to retrieve data from it whenever required.
- If tables in a database are not even in the 1st Normal Form, it is considered a bad database design.
- Rules for First Normal Form
- The first normal form expects you to follow a few simple rules while designing your database, and they are:
- Rule 1: Single Valued Attributes
- Each column of your table should be single-valued which means they should not contain multiple values.
- Rule 2: Attribute Domain should not change
- This is more of a "Common Sense" rule.
- In each column the values stored must be of the same kind or type.
- For example: If you have a column DOB to save date of birth of a set of people, then you cannot or you must not save 'names' of some of them in that column along with 'date of birth' of others in that column. It should hold only 'date of birth' for all the records/rows.
- Rule 3: Unique name for Attributes/Columns
- This rule expects that each column in a table should have a unique name. This is to avoid confusion at the time of retrieving data or performing any other operation on the stored data.
- If one or more columns have same name, then the DBMS system will be left confused.
- Rule 4: Order doesn't matters
- This rule says that the order in which you store the data in your table doesn't matter.
- Example:
- Roll_no Name Subject
- 101 Akon OS, CN
- 103 Ckon Java
- 102 Bkon C, C++
- Description:
- Our table already satisfies 3 rules out of the 4 rules.
- All our column names are unique.
- We have not inter-mixed different type of data in columns.
- In subject, 2 subject have opted for more than 1 subject and we have stored the subject names in a single column.
- But as per the 1st Normal form each column must contain atomic value.
- How to solve this Problem?
- It's very simple, because all we have to do is break the values into atomic values.
- Here is our updated table and it now satisfies the First Normal Form.
- Example:
- Roll_no Name Subject
- 101 Akon OS
- 101 Akon CN
- 103 Ckon Java
- 102 Bkon C
- 102 Bkon C++
- Result:
- A few values are getting repeated.
- All values for the subject column are now atomic for each record/row.
- Using the First Normal Form, data redundancy increases.
- There will be many columns with same data in multiple rows.
Tags:
DBMS