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

Normal Forms

Dbms normal forms

Uploaded by

Praveena G
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

Normal Forms

Dbms normal forms

Uploaded by

Praveena G
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 23

Problems caused by redundancy in DBMS

• 1. Wasted Storage
• 2. Data Anomalies
• Update Anomalies
• Insertion Anomalies
• Deletion Anomalies
• 3. Increased Complexity
• 4. Performance Issues
• 5. Data Integrity Issue

• Example
| OrderID | CustomerName | Product | CustomerAddress
||-------|--------------|-----------|-----------------|
|1 | Madhu | Laptop | Hyderabad |
|2 | Madhu | Mouse | Hyderabad |
|3 | Naveen | Keyboard | Bengaluru |
• Problems:

1. Update Anomaly: If Madhu moves to a new address, you'd have to update multiple rows. If
you forget to update all the rows, it leads to inconsistent data.

2. Insertion Anomaly: To insert a new order for Madhu, you have to re-enter his address,
leading to further redundancy.

3. Deletion Anomaly: If you decide to delete the order with the mouse, you might be tempted
to delete Madhu's details entirely, but that would remove crucial data associated with the
laptop order.
1. Customers Table:
| CustomerID | CustomerName | CustomerAddress
|------------|--------------|-------------------|
| 101 | Madhu | Hyderabad |
| 102 | Naveen | Bengaluru |

2. Orders Table:
| OrderID | CustomerID | Product |
|---------|------------|----------|
|1 | 101 | Laptop |
|2 | 101 | Mouse |
|3 | 102 | Keyboard |

This design reduces redundancy and eliminates the anomalies.


Decompositions and its problems in DBMS

• 1. Loss of Information or "lossy decomposition."


• 2. Loss of Functional Dependency
• 3. Increased Complexity
• 4. Redundancy
• 5. Performance Overhead
Functional Dependencies and its reasoning in DBMS

Functional Dependencies (FD)


A functional dependency `X→Y’ between two sets of attributes X
and Y in a relation R is defined as:
if two tuples (rows) of R have the same value for attributes X, then
they must also have the same
values for attributes Y.
In other words, the values of X determine the values of Y.
sid | sname | zipcode | cityname | state |
|------|----------|---------|----------------|----------------|
| S001 | Aarav | 110001 | New Delhi | Delhi |
| S002 | Priyanka | 400001 | Mumbai | Maharashtra |
| S003 | Rohit | 700001 | Kolkata | West Bengal |
| S004 | Ananya | 560001 | Bengaluru | Karnataka |
| S005 | Kartik | 600001 | Chennai | Tamil Nadu |
| S006 | Lakshmi | 500001 | Hyderabad | Telangana |
| S007 | Aditya | 160017 | Chandigarh | Chandigarh |
sid→sname
zipcode→cityname
cityname→state
NORMAL FORMS
• 1. First Normal Form (1NF)

• Each table should have a primary key.

• Atomic values: Each attribute (column) of a table should hold


only a single value, meaning no repeating groups or arrays.

• All entries in any column must be of the same kind.


• First Normal Form (1NF) is the first step in the
normalization process of organizing data within a
relational database to reduce redundancy and improve
data integrity.

• 1. Atomic Values
• 2. Should not have multiple values
• 3.All attributes should be unique
| Student_ID | Subjects |
|------------|-------------------|
| 1 | Math, English |
| 2 | English, Science |
| 3 | Math, History |

| Student_ID | Subject |
|------------|-----------|
| 1 | Math |
| 1 | English |
| 2 | English |
| 2 | Science |
| 3 | Math |
| 3 | History |
• Second Normal Form (2NF)

• It meets all the requirements of 1NF.

• Should not have partial dependencies.


1.It is already in 1NF

2. No Partial Dependencies:

| Student_ID | Course_ID| Course_Name | Faculty |


|------------|---------------------|---------------|--------- ----|
|1| C1 | Math | Mr. A |
|1| C2 | English | Ms. B |
|2| C1 | Math | Mr. A |
|3| C3 | History | Ms. C |
|Student_ID|Course_ID | Course_ID | Course_Name | Faculty |
|------------|-----------| |-----------|---------------|-------------|
|1 | C1 | | C1 | Math | Mr. A |
|1 | C2 | | C2 | English | Ms. B |
|2 | C1 | | C3 | History | Ms. C |
|3 | C3 |

Course Table
StudentCourse Table
• Third Normal Form (3NF)

• It meets all the requirements of 2NF.

• There should be no transitive dependencies.


• 1. It is already in 2NF
• 2. No Transitive Dependencies

| Product_ID | Product_Name | Vendor_Name | Vendor_Address |


|----------------|----------------------|--------------------|------------------------|
| P1 | Laptop | TechCorp | 123 Tech St. |
| P2 | Mouse | TechCorp | 123 Tech St. |
| P3 | Chair | FurniShop | 456 Furni R |
Product Table

| Product_ID | Product_Name | Vendor_Name |


|----------------|----------------------|--------------------|
| P1 | Laptop | TechCorp |
| P2 | Mouse | TechCorp |
| P3 | Chair | FurniShop |

Vendor Table

| Vendor_Name | Vendor_Address |
|---------------------|-----------------------|
| TechCorp | 123 Tech St. |
| FurniShop | 456 Furni Rd. |
• Boyce-Codd Normal Form (BCNF)

• Meets all requirements of 3NF.

• For any non-trivial functional dependency, X → Y,


X should be a superkey.
Initial Table

| Student | Professor | Topic |


|------------|--------------|--------|
| Alice | Mr. A | Math |
| Bob | Mr. B | Math |
| Charlie | Mr. C | Physics|

StudentSupervision Table: ProfessorTopic Table:

| Student | Professor | | Professor | Topic |


|------------|--------------| |-----------|-----------|
| Alice | Mr. A | | Mr. A | Math |
| Bob | Mr. B | | Mr. B | Math |
| Charlie | Mr. C | | Mr. C | Physics |
• Fourth Normal Form (4NF)

• Meets all the requirements of BCNF.

• There shouldn’t be any multi-valued dependency for a


superkey. This deals with separating independent multiple
relationships, ensuring that you cannot determine multiple
sets of values in a table from a single key attribute.
Initial Table

| Student_ID | Hobby | Course |


|------------|--------------|------------- -|
| S1 | Painting | Math |
| S1 | Painting | Physics |
| S1 | Hiking | Math |
| S1 | Hiking | Physics |
| S2 | Reading | Chemistry |
| S2 | Reading | Biology |
StudentCourses Table:
StudentHobbies Table:
| Student_ID | Course |
| Student_ID | Hobby |
|------------|---------------|
|----------------|------------|
| S1 | Math |
| S1 | Painting |
| S1 | Physics |
| S1 | Hiking |
| S2 | Chemistry |
| S2 | Reading |
| S2 | Biology |
• Fifth Normal Form (5NF or Project-Join Normal Form -
PJNF)

• It deals with cases where certain projections of your data


must be recreatable from other projections.
• Sixth Normal Form (6NF)

• Often considered when dealing with temporal databases


(databases that have time-dependent data).

• Deals with how data evolves over time and is less commonly
discussed in most relational database design contexts.

You might also like