Normal forms 1NF

Comprehensive study notes, diagrams, and exam preparation for Normal forms 1NF.

Normal Forms: 1NF

Definition

First Normal Form (1NF) is the fundamental property of a relational database that ensures a table is organized into a structured format where each column contains only atomic (indivisible) values and each record is unique. A table is in 1NF if it satisfies the requirement that all entries in a column are of the same data type and there are no repeating groups of data.


Main Content

1. Atomicity of Data

  • Each cell in the table must contain a single value. Multi-valued attributes (e.g., a cell containing multiple phone numbers separated by commas) are prohibited.
  • Atomicity ensures that database queries can filter and sort data accurately without complex string parsing.

2. Uniqueness of Rows

  • Every row in the table must be uniquely identifiable, usually through a Primary Key.
  • This prevents ambiguity when retrieving or updating specific records.

3. Consistency of Columns

  • All entries within a specific column must be from the same domain or data type.
  • The order in which data is stored does not impact the integrity of the data, allowing the database engine to optimize storage.

Working / Process

1. Identify Non-Atomic Columns

  • Scan the table for cells containing comma-separated lists, brackets, or multiple values.
  • Example: If a "Student" table has a "Courses" column with "Math, Physics", this violates 1NF.

2. Flatten the Data

  • Create new rows for each individual piece of data that was previously bundled together.
  • Ensure that the primary key is repeated for these new rows to maintain the relationship.
BEFORE (Violates 1NF):
+---------+--------------+
| ID      | Skills       |
+---------+--------------+
| 101     | Java, Python |
+---------+--------------+

AFTER (In 1NF):
+---------+--------------+
| ID      | Skills       |
+---------+--------------+
| 101     | Java         |
| 101     | Python       |
+---------+--------------+

3. Assign a Primary Key

  • Ensure that every row is identifiable. If no unique identifier exists, create a composite key using the combination of existing columns.
  • This stabilizes the table structure for future normalization steps like 2NF and 3NF.

Advantages / Applications

  • Improves Data Integrity: By enforcing atomicity, the database prevents errors caused by partial data matching.
  • Facilitates Efficient Querying: SQL commands like SELECT, WHERE, and ORDER BY perform significantly faster and more reliably on 1NF-compliant tables.
  • Standardizes Data Structure: It serves as the essential foundation for more advanced normalization, allowing for easier maintenance and scalability of complex database systems.

Summary

First Normal Form (1NF) is the foundational rule in database design that mandates all columns contain only single, atomic values and that no repeating groups exist within rows. It is achieved by breaking down multi-valued cells into individual rows and assigning a unique primary key to distinguish every record.

  • Key Concepts: Atomicity, Uniqueness, Data Consistency.
  • Goal: Eliminate repeating groups and structured mess.
  • Important Terms: Atomic Value, Primary Key, Relational Schema.