Beginner LevelSQL & MySQL
What is Database Normalization (1NF, 2NF, 3NF, BCNF)?
❓ Interview Prompt: Explain Database Normalization goals, anomalies (Insert, Update, Delete anomalies), First Normal Form (1NF), Second Normal Form (2NF), and Third Normal Form (3NF).
Database Normalization organizes relational schemas to minimize data redundancy and eliminate modification anomalies:
3 Normalization Steps:
1
First Normal Form (1NF): Eliminate repeating groups; ensure all column values are atomic (single values).
2
Second Normal Form (2NF): Meets 1NF, and all non-key attributes are fully functionally dependent on the entire Primary Key (eliminates partial dependencies).
3
Third Normal Form (3NF): Meets 2NF, and no non-key attribute depends on another non-key attribute (eliminates transitive dependencies).
Code Implementation Example
sql
-- 3NF Compliant Schema: Split Customers and Orders into separate normalized tables
CREATE TABLE customers (
customer_id INT PRIMARY KEY,
customer_name VARCHAR(100)
);
CREATE TABLE orders (
order_id INT PRIMARY KEY,
customer_id INT,
order_date DATE,
FOREIGN KEY (customer_id) REFERENCES customers(customer_id)
);💡3NF Schema separating Customers and Orders to eliminate redundancy.
🎯 Interview Key Takeaway
Normalize database schemas up to 3NF to eliminate duplicate data and prevent insert/update/delete anomalies.
#SQL#Normalization#1NF#2NF#3NF#Beginner
Back to all SQL & MySQL Questions→