Normalization
Normalization एक प्रोसेस है डेटाबेस में डाटा को organize करने की, जिससे redundancy काम हो एवं डाटा इंटीग्रिटी में सुधर हो। Normalization का मुख्य उद्देश्य एक टेबल को एक से अधिक टेबल में विभाजित करना है एवं सबंध (रिलेशनशिप) के आधार पर आपस में link किया जाता है।
इस प्रकिया में normalization के नियमों का पालन किया जाता है (इन्ही नियमों को normalization के नियम कहते है) जिससे डेटाबेस कुशलता से structured रहे। structured डेटाबेस में डाटा query, updatation आदि operation के टाइम काम लगता है।
NOTE – PDF लिंक निचे है – Click Here
Types of Normalization
- First Normal Form (1NF)
- Second Normal Form (2NF)
- Third Normal Form (3NF)
- Boyce-Codd Normal Form (BCNF)
- Fourth Normal Form (4NF)
First Normal Form (1NF)
Normalization के प्रथम नियमानुसार टेबल में एटॉमिक (atomic) values होनी चाहिए या टेबल के हर एक कॉलम में केवल और केवल एक वैल्यू होनी चाहिए।
Example (Normalization के बिना)
OrderID | CustomerName | ProductName | Quantity | UnitPrice |
1 | Alice | Pen | 10 | 1 |
1 | Alice | Notebook, Laptop | 5 | 3 |
2 | Bob | Pencil | 20 | 0.5 |
Normalization के बाद
OrderID | CustomerName | ProductName | Quantity | UnitPrice |
1 | Alice | Pen | 10 | 1 |
1 | Alice | Notebook | 5 | 3 |
1 | Alice | Laptop | 5 | 3 |
2 | Bob | Pencil | 20 | 0.5 |
Second Normal Form (2NF)
Normalization के प्रथम नियमानुसार टेबल (relation) में First Normal Form में होने के साथ-साथ टेबल के सभी non-key attributre पूर्णतयः primary key पर निर्भर हो।
Order Table (Not in 2NF)
OrderID | CustomerName | ProductName | Quantity | UnitPrice |
---|---|---|---|---|
1 | Alice | Pen | 10 | 1 |
1 | Alice | Notebook | 5 | 3 |
2 | Bob | Pencil | 20 | 0.5 |
Issues with the Table (Not in 2NF)
Redundancy: CustomerName and CustomerAddress repeat हो रहे है product order के लिए।
Partial Dependency: CustomerName and CustomerAddress दोनों केवल OrderID पर depend है, जो की composite primary ((OrderID, ProductID)) का हिस्सा है।
Second Normal Form (2NF) के बाद
Customers Table:
CustomerID | CustomerName | CustomerAddress |
---|---|---|
1 | Alice | 123 Main St |
2 | Bob | 456 Oak St |
Products Table:
ProductID | ProductName | UnitPrice |
---|---|---|
101 | Pen | 1.00 |
102 | Notebook | 3.00 |
103 | Pencil | 0.50 |
Orders Table:
OrderID | CustomerID |
---|---|
1 | 1 |
2 | 2 |
OrderDetails Table:
OrderID | ProductID | Quantity |
---|---|---|
1 | 101 | 10 |
1 | 102 | 5 |
2 | 103 | 20 |
Third Normal Form (3NF)
टेबल तीसरे फॉर्म में होने के लिए पहले 1ंNF एवं 2NF में होनी चाहिए इसके साथ ही सभी attribute प्राइमरी key पर depend होने चाहिए है। इसमें फॉर्म में transitive dependancy (एक non-key attributes किसी दूसरे non-key attributes पर देपेंद न हो) नहीं होनी चाहिए।
Order Table (Not in 3NF):
OrderID | CustomerID | CustomerName | CustomerAddress | ProductID | ProductName | Quantity | UnitPrice | TotalPrice |
1 | 1 | Alice | 123 Main St | 101 | Pen | 10 | 1 | 10 |
1 | 1 | Alice | 123 Main St | 102 | Notebook | 5 | 3 | 15 |
2 | 2 | Bob | 456 Oak St | 103 | Pencil | 20 | 0.5 | 10 |
Customers Table:
CustomerID | CustomerName | CustomerAddress |
---|---|---|
1 | Alice | 123 Main St |
2 | Bob | 456 Oak St |
Products Table:
ProductID | ProductName | UnitPrice |
---|---|---|
101 | Pen | 1.00 |
102 | Notebook | 3.00 |
103 | Pencil | 0.50 |
Orders Table:
OrderID | CustomerID |
---|---|
1 | 1 |
2 | 2 |
OrderDetails Table:
OrderID | ProductID | Quantity | UnitPrice |
---|---|---|---|
1 | 101 | 10 | 1.00 |
1 | 102 | 5 | 3.00 |
2 | 103 | 20 | 0.50 |
Boyce-Codd Normal Form (BCNF)
इस नार्मल में टेबल 3NF होने के साथ-साथ, हर एक functional dependancy (A -> B), जहाँ A एक सुपर key है। BCNF 3NF का stricter version है।
Example Without BCNF
Student Courses Table (Not in BCNF):
StudentID | CourseID | Instructor |
---|---|---|
1 | 101 | Prof. Smith |
1 | 102 | Prof. Jones |
2 | 101 | Prof. Smith |
3 | 103 | Prof. Adams |
Issues with the Table (Not in BCNF)
- Functional Dependency: यहाँ पर instructor depends है CourseID, लेकिन CourseID एक सुपर key नहीं है। StudentID and CourseID एक primary key बनाया जा सकता है।
Students Table:
StudentID | CourseID |
---|---|
1 | 101 |
1 | 102 |
2 | 101 |
3 | 103 |
Courses Table:
CourseID | Instructor |
---|---|
101 | Prof. Smith |
102 | Prof. Jones |
103 | Prof. Adams |
Fourth Normal Form (4NF)
टेबल को Fourth Normal Form में होने के लिए 3NF एवं BCNF के साथ-साथ multi-valued dependencies न हो।
Student Activities Table (Not in 4NF):
StudentID | Activity | Skill |
---|---|---|
1 | Football | Painting |
1 | Football | Dancing |
1 | Basketball | Painting |
1 | Basketball | Dancing |
2 | Football | Singing |
2 | Swimming | Singing |
Issues with the Table (Not in 4NF)
- Multi-Valued Dependency: एक स्टूडेंट की multiple activities and multiple skills है, जो की redundancy and data anomalies problem को क्रिएट करती है।
Example With 4NF
टेबल को 4NF में करने के लिए, हमें multi-valued dependencies को रिमूव करने पड़ेंगे, जिसके के लिए टेबल को दो अलग-अलग टेबल्स में विभाजित करेंगे किसी भी टेबल में multi-valued dependencies नहीं रहेंगी।
StudentActivities Table:
StudentID | Activity |
---|---|
1 | Football |
1 | Basketball |
2 | Football |
2 | Swimming |
StudentSkills Table:
StudentID | Skill |
---|---|
1 | Painting |
1 | Dancing |
2 | Singing |
इस article में हमने नार्मल फॉर्म्स के बारें पढ़ा, यदि कोई doubt हो तो comment में पूछ सकते है। आर्टिकल पसंद आये हो तो दोस्तों के साथ भी शेयर करें। धन्यवाद !