0
0
SQLquery~5 mins

First Normal Form (1NF) in SQL

Choose your learning style9 modes available
Introduction
First Normal Form (1NF) helps organize data in a table so that each piece of information is stored clearly and separately. This makes data easier to understand and use.
When you want to make sure each column in a table holds only one value.
When you notice a table has columns with multiple values in one cell.
When you want to avoid confusion and errors in your data by keeping it simple.
When preparing data for easy searching and updating.
When designing a new database to keep data clean from the start.
Syntax
SQL
CREATE TABLE table_name (
  column1 datatype PRIMARY KEY,
  column2 datatype NOT NULL,
  column3 datatype,
  ...
);

-- Ensure each column holds atomic (single) values only.
-- No repeating groups or arrays in columns.
1NF means each column must have atomic values, which means no lists or multiple values in one cell.
Each row should be unique, often ensured by a primary key.
Examples
A simple table where each column holds one value per row, meeting 1NF.
SQL
CREATE TABLE Students (
  StudentID INT PRIMARY KEY,
  Name VARCHAR(100),
  Age INT
);
Each order has one product and quantity per row, no multiple products in one cell.
SQL
CREATE TABLE Orders (
  OrderID INT PRIMARY KEY,
  ProductName VARCHAR(100),
  Quantity INT
);
PhoneNumber column holds one phone number per employee, not multiple numbers in one cell.
SQL
CREATE TABLE Employees (
  EmployeeID INT PRIMARY KEY,
  Name VARCHAR(100),
  PhoneNumber VARCHAR(15)
);
Sample Program
This creates a Books table that follows 1NF by storing one book title and one author per row.
SQL
CREATE TABLE Books (
  BookID INT PRIMARY KEY,
  Title VARCHAR(100),
  Author VARCHAR(100)
);

INSERT INTO Books (BookID, Title, Author) VALUES
(1, 'The Cat in the Hat', 'Dr. Seuss'),
(2, 'Green Eggs and Ham', 'Dr. Seuss');

SELECT * FROM Books;
OutputSuccess
Important Notes
If a column has multiple values, split them into separate rows or columns.
Always choose a primary key to uniquely identify each row.
1NF is the first step to organizing your data well before moving to more advanced forms.
Summary
1NF means each table column holds only one value per row.
No lists or multiple values allowed in a single cell.
Helps keep data simple, clear, and easy to work with.