Skip to content
GitHub

Third Normal Form (3NF)

3NF ၏ စည်းမျဉ်းများ

Section titled “3NF ၏ စည်းမျဉ်းများ”

Table တစ်ခုဟာ Third Normal Form (3NF) အဆင့်ကို ရောက်ဖို့ဆိုရင်:

  1. 2NF အဆင့်မှာ ရှိပြီးသား ဖြစ်ရမယ်။
  2. Transitive Dependency (တစ်ဆင့်ခံ မှီခိုမှု) မရှိရဘူး။ Table ထဲက Non-Key Column (Primary Key မဟုတ်တဲ့ Column) တွေဟာ အချင်းချင်း မှီခိုနေတာမျိုး လုံးဝ မရှိရပါဘူး။ Column တိုင်းဟာ Primary Key အပေါ်မှာပဲ တိုက်ရိုက် မှီခိုရပါမယ်။

လွယ်လွယ်မှတ်ရရင်: “Column တိုင်းဟာ Primary Key အကြောင်းကိုပဲ ပြောရမယ်၊ တခြား Column အကြောင်း မပြောရဘူး။” (Nothing but the key!)


Transitive Dependency ဆိုတာ ဘာလဲ?

Section titled “Transitive Dependency ဆိုတာ ဘာလဲ?”

Transitive Dependency (တစ်ဆင့်ခံ မှီခိုမှု) ဆိုတာ သချာၤသဘောတရားအရ A -> B ဖြစ်ပြီး B -> C ဖြစ်ရင် A -> C ဖြစ်တယ် ဆိုတဲ့ သဘောတရားမျိုးပါ။

Database မှာဆိုရင် Primary Key က A၊ Non-Key Column တွေက B နဲ့ C လို့ သဘောထားကြည့်ပါ။

  • A (Primary Key) ကို သိရင် B ကို သိနိုင်တယ်။
  • ဒါပေမဲ့ C က A ကို တိုက်ရိုက် မမှီခိုဘဲ B ကနေတစ်ဆင့် မှီခိုနေတာမျိုး (B -> C) ကို Transitive Dependency လို့ ခေါ်ပါတယ်။

2NF က Orders Table ကို ပြန်ကြည့်ရအောင်

Section titled “2NF က Orders Table ကို ပြန်ကြည့်ရအောင်”

2NF အဆင့်တုန်းက ခွဲထုတ်ခဲ့တဲ့ Orders Table မှာ:

  • OrderID (Primary Key)
  • CustomerName (Non-Key)
  • CustomerAddress (Non-Key)
  • OrderDate (Non-Key) တွေ ပါဝင်ပါတယ်။

ဒီမှာ ပြဿနာက ဘာလဲဆိုတော့: CustomerAddress (လိပ်စာ) ဟာ OrderID (ဘောင်ချာနံပါတ်) အပေါ်မှာ တိုက်ရိုက် မှီခိုနေတာ မဟုတ်ပါဘူး။ တကယ်တော့ CustomerAddress ဟာ CustomerName (ဝယ်သူနာမည်) အပေါ်မှာ မှီခိုနေတာပါ။ (CustomerName -> CustomerAddress).

ဒါကြောင့် Non-Key အချင်းချင်း မှီခိုနေတဲ့ Transitive Dependency ဖြစ်နေပါတယ်။

2NF မှ 3NF သို့ ပြောင်းလဲခြင်း

Section titled “2NF မှ 3NF သို့ ပြောင်းလဲခြင်း”

ဒီ ပြဿနာကို ဖြေရှင်းဖို့ 3NF စည်းမျဉ်းအရ Non-Key အချင်းချင်း မှီခိုနေတဲ့ အပိုင်းကို သီးသန့် Table အသစ်တစ်ခုအဖြစ် ထပ်မံ ခွဲထုတ် ပေးရပါမယ်။

Orders Table ထဲက Customer နဲ့ ပတ်သက်တဲ့ အချက်အလက်တွေကို Customers ဆိုတဲ့ Table အသစ်တစ်ခု လုပ်ပြီး ရွှေ့လိုက်ပါမယ်။ ပြီးရင် Orders Table နဲ့ ချိတ်ဆက်ဖို့ CustomerID ဆိုတဲ့ Foreign Key လေးပဲ ချန်ထားခဲ့ပါမယ်။

Orders Table (3NF)Customers Table (3NF)
3NF Orders Table
3NF Customers Table
CustomerID ကို Foreign Key အဖြစ်ပဲ ထားတော့မယ်Customer အချက်အလက် သီးသန့်

အခုဆိုရင် ဇယားတိုင်းမှာ Non-Key Column တွေ အချင်းချင်း မှီခိုတာ မရှိတော့ပါဘူး။ အရာအားလုံးဟာ သက်ဆိုင်ရာ Primary Key အပေါ်မှာပဲ တိုက်ရိုက် မှီခိုနေတော့တဲ့အတွက် Third Normal Form (3NF) စည်းမျဉ်းနဲ့ အပြည့်အဝ ကိုက်ညီသွားပါပြီ။

လက်တွေ့ လုပ်ငန်းခွင် အများစုမှာ ဒီ 3NF အဆင့်အထိ လုပ်ဆောင်နိုင်ရင်ပဲ Database ဒီဇိုင်းက လုံလောက်စွာ ကောင်းမွန်နေပြီလို့ သတ်မှတ်ကြပါတယ်။