Basic-level SQL interview questions for Software Engineer positions.
1. What is normalization and why is it important?
Answer: Normalization organizes data to reduce redundancy and improve integrity. Normal forms: 1NF (atomic values), 2NF (no partial dependencies), 3NF (no transitive dependencies). Benefits: Less storage, easier updates, data consistency. Trade-off: May need JOINs for queries.
-- Unnormalized (bad) CREATE TABLE orders ( id INT, customer_name VARCHAR, customer_email VARCHAR, product_name VARCHAR, product_price DECIMAL ); -- Normalized (good) - 3NF CREATE TABLE customers (id INT PRIMARY KEY, name VARCHAR, email VARCHAR); CREATE TABLE products (id INT PRIMARY KEY, name VARCHAR, price DECIMAL); CREATE TABLE orders ( id INT PRIMARY KEY, customer_id INT REFERENCES customers(id), product_id INT REFERENCES products(id) );