- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is 1NF in DBMS? Explain with examples
A relation is in 1NF if it contains atomic values. It states that an attribute of a table cannot hold multiple values. It must hold only single-values attributes. First normal form disallows the multi-valued attributes, composite attributes, and their combinations.
Requirements
The requirements to be considered while designing 1 NF are explained below −
Each table has a primary key (minimal set of attributes which can uniquely identify a record).
The values in each column of a table are atomic (no multi0value attributes are allowed).
There are no repeating groups (two columns do not store similar information in the same table).
Example 1
Consider a relation student (rollno, name, branch, address, phone).
Rollno | Name | Branch | Address | Phone |
---|---|---|---|---|
1 | AAA | CSE | Hyderabad | 3242344,4564555,3112453 |
2 | BBB | ECE | Delhi | 3452245,4323245 |
The above relation is not in 1NF because the phone is a multivalued attribute, which is having multiple numbers for a single person.
Now we represent the above table by creating a new row for each phone number as shown below −
Rollno | Name | Branch | Address | Phone |
---|---|---|---|---|
1 | AAA | CSE | Hyderabad | 3242344 |
1 | AAA | CSE | Hyderabad | 4564555 |
1 | AAA | CSE | Hyderabad | 3112453 |
2 | BBB | ECE | Delhi | 3452245 |
2 | BBB | ECE | Delhi | 4323245 |
The above table contains redundant data due to phone numbers, as for each phone number, we have to repeat all the information of the student. So the phone attribute should be separated from the above table.
We divide or decompose the above table R into two tables which is the concept of normalization −
R1(key, multivalued attribute), R2(R-multivalued attribute)
=>R1(rollno, phone), R2(rollno, name, branch, address).
Steps to decompose the 1NF table are as follows −
Place all items that appear in the repeating group in a new table.
Find a primary key for each new table produced.
Duplicate in a new table the primary key of the table from which the repeating group was extracted or vice versa.
R1
Rollno | Phone |
---|---|
1 | 3242344 |
1 | 4564555 |
1 | 3112453 |
2 | 3452245 |
2 | 4323245 |
R2
Rollno | Name | Branch | Address |
---|---|---|---|
1 | AAA | CSE | Hyderabad |
2 | BBB | ECE | Delhi |
R1 and R2 are in 1NF.
Key of R1 = rollno
Key of R2 = (rollno, phone)
Example 2
Consider another example to check whether the given table is 1NF or not, if not try to convert into 1NF.
Un-normalized table R1
Course | Content |
---|---|
Programming | C,C++,java |
Scripting language | HTML,javascript |
Normalized table (1NF)
Course | Content |
---|---|
Programming | C |
Programming | C++ |
Programming | Java |
Scripting language | HTML |
Scripting language | javascript |