1.
Designing a Table in First Normal Form (1NF)
Write a SQL query to normalize a table into First Normal Form (1NF).
2. Resolving Partial Dependencies for Second Normal Form (2NF)
Write a SQL query to resolve partial dependencies and achieve 2NF.
3. Eliminating Transitive Dependencies for Third Normal Form (3NF)
Write a SQL query to eliminate transitive dependencies and achieve 3NF.
4. Achieving Boyce-Codd Normal Form (BCNF)
Write a SQL query to resolve overlapping candidate keys and achieve BCNF.
Sample Answer for first Normal form :
-- Original table with repeating groups.
CREATE TABLE Orders (
OrderID INT,
CustomerName VARCHAR(100),
ProductNames VARCHAR(MAX) -- Comma-separated list of products.
);
-- Normalize the table into 1NF by splitting repeating groups.
CREATE TABLE Orders_1NF (
OrderID INT,
CustomerName VARCHAR(100),
ProductName VARCHAR(100)
);
Explanation:
Purpose of the Query :
o The goal is to eliminate repeating groups and ensure atomic values in each
column, achieving 1NF.
Key Components :
o Orders_1NF: A normalized table where each product is stored in a separate
row.
o Each column contains only one value per row.
Why use 1NF? :
o 1NF ensures that data is stored in a structured format, making it easier to
query and maintain.
o It eliminates redundancy caused by repeating groups.
Real-World Application :
o In an e-commerce system, storing each product in a separate row simplifies
order processing.