Normalization & Functional Dependencies (FDs)
Problem Scenario: Socho tum ek hi register me saara hisaab rakhte ho. Usme customer ki details, uske order ki details, sab mix hai. Isse 3 tarah ki "sar-dardi" (Anomalies) hoti hain: Insertion, Deletion, aur Updation Anomaly. Inhi problems ko solve karne ka process Normalization hai.
A. Functional Dependency (FD)
FD ka simple matlab hai dependency. Agar attribute 'A' se hum attribute 'B' ko uniquely pehchaan sakte hain, to hum kehte hain B, A par functionally dependent hai. Ise likhte hain: A → B (Read as: A determines B). Example: Aadhaar_Number → Name.
B. Normal Forms (1NF, 2NF, 3NF, BCNF)
- 1NF (First Normal Form): Har cell me sirf ek (atomic) value honi chahiye. No multiple values.
- 2NF (Second Normal Form): Koi bhi non-key attribute, primary key ke adhure hisse par depend na kare. Ise Partial Dependency kehte hain.
- 3NF (Third Normal Form): Koi bhi non-key attribute, kisi dusre non-key attribute par depend na kare. Ise Transitive Dependency kehte hain.
- BCNF (Boyce-Codd Normal Form): Yeh 3NF ka stricter version hai. Iske rule ke anusaar, har non-trivial FD
X → Yme,Xhamesha ek Super Key hona chahiye.
C. How to Find Candidate Keys
Attribute Closure (X+): Ek attribute set 'X' ki "power" nikalna. Yani, 'X' se FDs ka use karke aap aur kaun-kaun se attributes nikal sakte ho.
The Golden Trick: FDs ke Right Hand Side (RHS) me dekho. Jo attribute kabhi nahi aaya, wo 100% har Candidate Key ka hissa hoga. Uss "essential attribute" set ka closure nikalo. Agar closure me saare attributes aa gaye, to wahi tumhara Candidate Key hai!