First Normal Form (1NF): atomic values and repeating groups
1NF definition, atomic value rule, repeating group problem, multi-valued attribute, row uniqueness, 1NF conversion steps
First Normal Form Rules
A table is in First Normal Form (1NF) when every cell contains exactly one value (atomic), every row is unique, and there are no repeating column groups.
Common Violations
Multi-value cells: Storing "Python, Java, SQL" in a single skills column. You cannot query for all developers who know Java without a LIKE hack.
Repeating column groups: Creating phone1, phone2, phone3 columns. You cannot support a fourth phone number without altering the schema.
How to Fix
-- Violates 1NF: multi-value cell
CREATE TABLE employees_bad (
emp_id INT PRIMARY KEY,
name VARCHAR(100),
skills VARCHAR(255) -- 'Python,Java,SQL'
);
-- Satisfies 1NF: separate table
CREATE TABLE employees (
emp_id INT PRIMARY KEY,
name VARCHAR(100) NOT NULL
);
CREATE TABLE employee_skills (
emp_id INT NOT NULL,
skill_name VARCHAR(50) NOT NULL,
PRIMARY KEY (emp_id, skill_name),
FOREIGN KEY (emp_id) REFERENCES employees(emp_id)
);The fix always follows the same pattern: extract the multi-valued attribute into its own table with a foreign key back to the parent. The composite PK on the new table enforces uniqueness automatically.
