0% found this document useful (0 votes)
4 views

Normalization

The document outlines the normalization process of a restaurant management system from 1NF to 5NF. It provides detailed examples of how to eliminate redundancy and ensure data integrity by restructuring tables for orders, items, waiters, prices, and special requests. Each normal form builds upon the previous one to achieve efficient data storage and improved query performance.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Normalization

The document outlines the normalization process of a restaurant management system from 1NF to 5NF. It provides detailed examples of how to eliminate redundancy and ensure data integrity by restructuring tables for orders, items, waiters, prices, and special requests. Each normal form builds upon the previous one to achieve efficient data storage and improved query performance.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Here are real-time examples of **1NF to 5NF** applied in a business scenario,

specifically a **restaurant management system**:

### **1NF (First Normal Form)**: Eliminate repeating groups and ensure that each
column contains atomic values.

#### Example: Unnormalized Table (Before 1NF)

| OrderID | CustomerName | Items |

|---------|--------------|-------------------------------------|

|1 | John | Burger, Fries, Coke |

|2 | Alice | Pizza, Salad, Water |

|3 | Bob | Burger, Fries, Soda, Ice Cream |

#### **1NF (First Normal Form) - Applied:**

Each column must have atomic values, meaning no multiple values in a single field. In
this case, we separate the items into individual rows.

| OrderID | CustomerName | Item |

|---------|--------------|-----------|

|1 | John | Burger |

|1 | John | Fries |

|1 | John | Coke |

|2 | Alice | Pizza |

|2 | Alice | Salad |
|2 | Alice | Water |

|3 | Bob | Burger |

|3 | Bob | Fries |

|3 | Bob | Soda |

|3 | Bob | Ice Cream |

### **2NF (Second Normal Form)**: Achieve 1NF and remove partial dependencies. All
non-prime attributes must depend on the entire primary key.

#### **2NF (Second Normal Form) - Applied:**

Let's assume the `OrderID` and `CustomerName` together make the composite primary
key. The problem is that the `CustomerName` is dependent only on the `OrderID`, not
the whole key. Therefore, we split the table into two:

**Orders Table:**

| OrderID | CustomerName |

|---------|--------------|

|1 | John |

|2 | Alice |

|3 | Bob |

**OrderItems Table:**

| OrderID | Item |

|---------|-----------|

|1 | Burger |
|1 | Fries |

|1 | Coke |

|2 | Pizza |

|2 | Salad |

|2 | Water |

|3 | Burger |

|3 | Fries |

|3 | Soda |

|3 | Ice Cream |

### **3NF (Third Normal Form)**: Achieve 2NF and remove transitive dependencies.
Non-prime attributes should not depend on other non-prime attributes.

#### **3NF (Third Normal Form) - Applied:**

Let’s assume that the **Orders** table also includes the `WaiterID` who served the
order, but the **WaiterName** depends on the `WaiterID`. This creates a transitive
dependency where `WaiterName` depends on `WaiterID`, which in turn depends on the
`OrderID`. We separate this into a new table:

**Orders Table:**

| OrderID | CustomerName | WaiterID |

|---------|--------------|----------|

|1 | John | 101 |

|2 | Alice | 102 |

|3 | Bob | 101 |
**OrderItems Table:**

| OrderID | Item |

|---------|-----------|

|1 | Burger |

|1 | Fries |

|1 | Coke |

|2 | Pizza |

|2 | Salad |

|2 | Water |

|3 | Burger |

|3 | Fries |

|3 | Soda |

|3 | Ice Cream |

**Waiters Table:**

| WaiterID | WaiterName |

|----------|------------|

| 101 | Sam |

| 102 | Lisa |

### **BCNF (Boyce-Codd Normal Form)**: Every determinant must be a candidate key.

#### **BCNF (Boyce-Codd Normal Form) - Applied:**


If we now assume that each item ordered can only have one price, but the price depends
on both the `Item` and `OrderID` (which creates a non-candidate key dependency), we
can split out the price information into a new table to ensure BCNF.

**Orders Table:**

| OrderID | CustomerName | WaiterID |

|---------|--------------|----------|

|1 | John | 101 |

|2 | Alice | 102 |

|3 | Bob | 101 |

**OrderItems Table:**

| OrderID | Item | PriceID |

|---------|-----------|---------|

|1 | Burger | 1 |

|1 | Fries |2 |

|1 | Coke |3 |

|2 | Pizza |4 |

|2 | Salad |5 |

|2 | Water |6 |

|3 | Burger | 1 |

|3 | Fries |2 |

|3 | Soda |7 |

|3 | Ice Cream | 8 |
**Waiters Table:**

| WaiterID | WaiterName |

|----------|------------|

| 101 | Sam |

| 102 | Lisa |

**ItemPrices Table (New Table for Prices):**

| PriceID | Item | Price |

|---------|-----------|-------|

|1 | Burger | 5.99 |

|2 | Fries | 2.99 |

|3 | Coke | 1.50 |

|4 | Pizza | 7.99 |

|5 | Salad | 3.99 |

|6 | Water | 1.00 |

|7 | Soda | 1.75 |

|8 | Ice Cream | 4.00 |

### **4NF (Fourth Normal Form)**: Eliminate multi-valued dependencies (when a


record has multiple independent multi-valued facts about an entity).

#### **4NF (Fourth Normal Form) - Applied:**

Suppose a customer can order multiple items and also provide multiple special requests
(e.g., "extra cheese" or "no onions"). These requests are independent and should be
handled separately.
**Orders Table:**

| OrderID | CustomerName | WaiterID |

|---------|--------------|----------|

|1 | John | 101 |

|2 | Alice | 102 |

|3 | Bob | 101 |

**OrderItems Table:**

| OrderID | Item | PriceID |

|---------|-----------|---------|

|1 | Burger | 1 |

|1 | Fries |2 |

|1 | Coke |3 |

|2 | Pizza |4 |

|2 | Salad |5 |

|2 | Water |6 |

|3 | Burger | 1 |

|3 | Fries |2 |

|3 | Soda |7 |

|3 | Ice Cream | 8 |

**Waiters Table:**

| WaiterID | WaiterName |
|----------|------------|

| 101 | Sam |

| 102 | Lisa |

**ItemPrices Table:**

| PriceID | Item | Price |

|---------|-----------|-------|

|1 | Burger | 5.99 |

|2 | Fries | 2.99 |

|3 | Coke | 1.50 |

|4 | Pizza | 7.99 |

|5 | Salad | 3.99 |

|6 | Water | 1.00 |

|7 | Soda | 1.75 |

|8 | Ice Cream | 4.00 |

**SpecialRequests Table (New Table for Independent Requests):**

| OrderID | Request |

|---------|--------------------|

|1 | Extra Cheese |

|1 | No Onions |

|2 | No Ice in Drink |

|3 | No Ice in Drink |
### **5NF (Fifth Normal Form)**: Decompose tables to eliminate join dependencies.

#### **5NF (Fifth Normal Form) - Applied:**

If we further normalize by separating out a **Special Requests** table and ensuring the
decomposed relationships do not have redundancy when joined, we achieve 5NF.

At this stage, the database would be fully normalized, ensuring efficient storage and
minimal redundancy.

**Orders Table:**

| OrderID | CustomerName | WaiterID |

|---------|--------------|----------|

|1 | John | 101 |

|2 | Alice | 102 |

|3 | Bob | 101 |

**OrderItems Table:**

| OrderID | ItemID |

|---------|--------|

|1 |1 |

|1 |2 |

|1 |3 |

|2 |4 |

|2 |5 |

|2 |6 |
|3 |1 |

|3 |2 |

|3 |7 |

|3 |8 |

**Waiters Table:**

| WaiterID | WaiterName |

|----------|------------|

| 101 | Sam |

| 102 | Lisa |

**ItemPrices Table:**

| ItemID | Item | Price |

|--------|-----------|-------|

|1 | Burger | 5.99 |

|2 | Fries | 2.99 |

|3 | Coke | 1.50 |

|4 | Pizza | 7.99 |

|5 | Salad | 3.99 |

|6 | Water | 1.00 |

|7 | Soda | 1.75 |

|8 | Ice Cream | 4.00 |

**SpecialRequests Table:**
| OrderID | Request |

|---------|--------------------|

|1 | Extra Cheese |

|1 | No Onions |

|2 | No Ice in Drink |

|3 | No Ice in Drink |

### Conclusion:

Each normal form reduces redundancy and ensures data integrity. The restaurant
example shows how business data such as orders, items, and special requests can be
normalized from **1NF to 5NF**, ensuring efficient data storage and query
performance.

You might also like