1NF in DBMS
In Database Management Systems (DBMS), First Normal Form (1NF) is the basic level of normalization. A relation (or table) is said to be in 1NF if it meets the following conditions:
-
Atomicity: Each column contains only atomic (indivisible) values. This means no column should contain multiple values or sets of values (e.g., lists, arrays).
-
Uniqueness: Each row in the table must be unique, meaning that there should be no duplicate rows.
-
Consistency: The values in each column must be of a consistent data type (i.e., the same type of data should be stored in each column).
Key Characteristics of 1NF
Atomicity:
-
The table must have atomic values. Atomic values mean each field (column) should contain a single value, not a set of values. This is one of the most important characteristics of 1NF. For instance, if a cell contains multiple values like “John, Jane” or “A, B, C”, it violates 1NF.
-
Example: A table storing multiple phone numbers in a single column should be split so that each phone number is stored in a separate row or column.
Uniqueness of Rows:
-
Every row in the table must be unique. No two rows should be identical. This can typically be ensured by having a primary key.
Consistency in Column Types:
-
All values in a column should be of the same type. For instance, a column that stores dates should not contain any text values or numbers.
Example: Table Not in 1NF
Consider a table Student that contains information about students and their courses:
StudentID | Name | Courses |
---|---|---|
101 | Alice | Math, Science |
102 | Bob | History, Geography |
103 | Charlie | Math, Computer Science |
In this table, the Courses column violates 1NF because it contains multiple values (e.g., “Math, Science” and “History, Geography”) in a single cell. The values are not atomic.
Converting to 1NF
To convert the above table into 1NF, we need to split the multi-valued attributes into individual rows so that each column contains atomic values.
StudentID | Name | Course |
---|---|---|
101 | Alice | Math |
101 | Alice | Science |
102 | Bob | History |
102 | Bob | Geography |
103 | Charlie | Math |
103 | Charlie | Computer Science |
Now, each cell contains a single value, and the Courses column has been normalized to store one course per row. This satisfies the condition of atomicity in 1NF.
Benefits of 1NF
- Eliminates Redundancy: By breaking down multi-valued attributes, we reduce data redundancy, which helps in simplifying queries and reducing the chances of data anomalies.
- Improved Query Performance: The database is more efficient in handling queries because each row contains atomic, independent data.
- Foundation for Higher Normal Forms: 1NF is the foundation for other normal forms (such as 2NF and 3NF). Achieving 1NF is the first step in ensuring the database is normalized.
Example: Table Already in 1NF
Consider the following table Employee that is already in 1NF:
EmployeeID | Name | Department | Phone Number |
---|---|---|---|
E001 | John | HR | 123-456-7890 |
E002 | Alice | Finance | 234-567-8901 |
E003 | Bob | IT | 345-678-9012 |
In this table, each column contains atomic values, and there are no multiple values or sets of values in any column. Therefore, the table is in 1NF.
Conclusion
First Normal Form (1NF) ensures that:
- All columns contain atomic (indivisible) values.
- Each row is unique, with no duplicate records.
- All columns contain consistent data of the same type.
Achieving 1NF is the first step in database normalization, and it helps to simplify the structure of the data by removing repeating groups and multi-valued attributes. The next step in normalization is to move to Second Normal Form (2NF).