Interview's MateSQL Learning
Interview's Mate

SQL Learning

Foundations → production SQL

Visualizer

DSA Visualizer
All 32 lessons
Custom Playground
Try your own examples

Learning

System Design
31 architecture topics
SQL Learning
160 foundations → production topics
AI Engineering
160 LLM → backend topics
Data Science
160 Python → MLOps topics
Data Engineer
160 SQL → streaming topics
Docker
160 Docker learning topics
Kubernetes
160 K8s fundamentals → cloud
Java LearnSoon
Coming soon
Python Learn
Interview Q&A & internals
JavaScript Learn
Closures, async & DOM Q&A
Tech Learn
Search, practise & track Q&A
AI DSA Practice
Solve coding problems
Theme
Home
SQL topics
Lesson 103/ 160
06. Database Design, Normalization & Semi-Structured SQL

First Normal Form (1NF): Atomic Values & Repeating Groups

Eliminate repeating groups and ensure atomic cell values for 1NF.

BeginnerAtomic Values · Repeating Groups3 quiz questions
Practice SQL
In plain wordsDiagramExamples & theoryStep by stepWhen to use itInterview cluesMistakes to avoidQuiz (3)Practice

In plain words

One box, one value. If something can have many values, give each value its own row in another table.

Think of it like…

A contacts card with a fixed set of three phone boxes: the fourth number gets squeezed into a margin and nobody can find it. Store one phone number per line instead, and the list can be as long as it needs to be.

Where you’ve seen it

products(id, name, tags) with tags = 'red,summer,sale' can't use an index to find all 'sale' products and can't stop typos like 'sael'. Moving to product_tags(product_id, tag) with one row per tag makes WHERE tag = 'sale' a simple indexed lookup and lets a foreign key validate tags.

Words you’ll hear

Atomic value
A single value of the column's type, used as a whole.
Repeating group
Numbered columns (phone1, phone2…) or a list stuffed into one column.
Child table
A separate table with one row per value, linked by a foreign key.
Arrays / JSON
Supported by PostgreSQL; fine as a single value, not when you query the elements individually.

Visual diagram

Loading interactive diagram

Theory & example queries

The two classic violations

Lists in a column: tags, skills or phone numbers stored as comma-separated text. You can't index individual items, LIKE '%sale%' also matches 'wholesale', counting items needs string splitting, and nothing stops invalid or duplicate entries.

Repeating groups of columns: phone1, phone2, phone3 or q1_sales … q4_sales. They cap how many values you can store, leave most columns NULL, and force queries to check every column (WHERE phone1 = ? OR phone2 = ? OR phone3 = ?).

Finding a phone number, before and after

Before: WHERE phone1 = $1 OR phone2 = $1 OR phone3 = $1. After normalising to customer_phones(customer_id, phone): WHERE phone = $1, one indexed lookup.

Key takeaway: Lists and numbered columns become rows in a child table.

What "atomic" really means

Atomic is about how you use a value, not whether it could be split. A date has a year, month and day, but it's atomic because you treat it as one date. A full address can be atomic for a shipping label, but not if you regularly filter by city, in which case city deserves its own column.

PostgreSQL arrays and JSONB columns don't strictly break 1NF if they're treated as one value, and they're practical for things like a small list of display labels. Once you need to filter, join, count or validate the elements individually, a child table is usually the better design.

The child tableQuery example
1Input dataStart from the source rows or state that the statement sees.
This statement works with the current schema, configuration, or database state rather than a row dataset. The command still follows the same input → query → result flow.
2QuerySwitch dialects, then select a line or execution step to trace it.
query.sql
1CREATE TABLE product_tags (2  product_id bigint REFERENCES products (id),3  tag text NOT NULL,4  PRIMARY KEY (product_id, tag)5);
Logical execution order
Native / baseline

PostgreSQL is the lesson baseline unless noted otherwise.

Line 1 · Choose the target

Identify the table or database object the statement will modify.

1/5
3OutputInspect the representative rows, affected-row count, plan, or command status.
Expected output
CREATE TABLE

Note: Representative PostgreSQL status when products already exists and the table name is available.

4ExplanationConnect the result back to the SQL rule and the edge case it demonstrates.

Key takeaway: If you query the parts, store the parts separately.

Interactive walkthrough

How it works, step by step

Follow one practical SQL workflow from start to finish. Select any step or play through the flow.

Progress1/4
Step 1Review

Look for lists and numbered columns

Scan the schema for comma-separated values and column names ending in 1, 2, 3.

Focus at this step

tags = 'a,b,c' · phone1, phone2

What to watch at this step
Smell
LIKE '%…%' on a list
Tip: use ← → to move between steps

When to use it & trade-offs

What it is

A table is in First Normal Form (1NF) when every cell holds a single value of its column's type (no lists like 'red,blue,green'), there are no repeating groups of columns (no phone1, phone2, phone3), and each row can be identified by a key. Lists and repeated columns move into a separate child table with one row per value.

Why it matters: Comma-separated lists and numbered columns look convenient until you need to query them: "which products are tagged red?" turns into string matching, counts go wrong, and you can't add a fourth phone number without changing the schema. 1NF is the first thing interviewers check when you design a table.

When to reach for it

  • Tags, categories, skills and phone numbers with a variable count
  • Any value you need to search or count individually
  • Fixing tables with numbered columns

When to avoid or be careful

  • Storing lists as delimited strings
  • Adding column4 when column3 fills up
  • Splitting values that are always used whole (like a date) just to look "more atomic"

Child table vs array/JSON column vs delimited text

Child table (1NF)
Best for: Values you filter, count, join or validate

Strengths: Indexable, constraint-checked, unlimited values.

Watch out: One more table and a join to read the list.

Array / JSONB column
Best for: Small lists read and written as a whole

Strengths: No join; PostgreSQL can index arrays with GIN.

Watch out: Weaker validation and less portable.

Comma-separated text
Best for: Nothing you need to query

Strengths: Easy to write.

Watch out: Can't be indexed, validated or counted reliably.

Interview signals & numbers to know

When this topic comes up

  • “Normalise this table”
  • Comma-separated values in a column
  • phone1, phone2, phone3
  • “What is 1NF?”
  • LIKE '%…%' to search inside a list

Benchmarks & rules of thumb

1 -
value per cell
0 -
repeating groups of columns
1 row -
per value in the child table

Common mistakes & follow-ups

Common interview mistakes

  • Searching tags with LIKE '%sale%' and matching 'wholesale' too.
  • Designing phone1 to phone3 columns and then needing a fourth.
  • Assuming any array column automatically breaks 1NF, or that it's always fine.

Likely interviewer follow-ups

  • How would you redesign a table that stores skills as a comma-separated list?
  • Is a PostgreSQL array column a violation of 1NF?
  • What's the difference between 1NF and 2NF?
Interview tip: Show the tags example, the LIKE problem it causes, and the child table that fixes it. A concrete before-and-after is a much stronger answer than reciting "atomic values".

Knowledge check

Loading quiz

Put it into practice

Practice related interview Q&A

Apply First Normal Form (1NF): Atomic Values & Repeating Groups with hands-on SQL practice and interview Q&A.

Open SQL Practice →SQL interview Q&A
Previous topic
Functional Dependencies & Candidate Keys
Next topic
Second Normal Form (2NF): Eliminating Partial Dependencies