Multiple Column Relationships

Multiple Column Relationships

Power BI ရဲ့ Tabular Model က Table တွေ Relationship ချိတ်တဲ့ အချိန်မှာ Column တစ်ခု ပေါ်ပဲ မူတည်ပြီး ချိတ်လို့ရပါတယ်။ ဒါပေမဲ့ တချို့ Model တွေမှာက Column တစ်ခုထက်ပိုပြီး ချိတ်မှ တွက်လို့ရတာတွေ ရှိပါတယ်။

ဥပမာ။ Sales model တစ်ခုကို လေ့လာပါမယ်။ ပုံမှန်အားဖြင့် Sales Model မှာ Fact table ဖြစ်တဲ့ Sales နဲ့ Dimension tables တွေ ဖြစ်တဲ့ Product နဲ့ Customer ပါပါမယ်။ အဲဒီအချိန်မှာ Order တစ်ချို့ရဲ့ Product တွေကို Discount ပေးမဲ့ table တစ်ခုကို ထပ်ထည့်မယ်ဆိုရင် ထပ်ထည့်တဲ့ table မှာ SalesOrderNumber, ProductKey ဆိုတဲ့ Column နှစ်ခုကို သုံးပြီး Sales နဲ့ ချိတ်နိုင်မှ Discount အဖြေကို တွက်နိုင်မှာ ဖြစ်ပါတယ်။ enter image description here

နည်းလမ်း ၁။ ပထမ နည်းလမ်းက ချိတ်မဲ့ table နှစ်ခုလုံးမှာ ချိတ်ချင်တဲ့ column နှစ်ခုကို Merge လုပ်ပြီး Composite Key အနေနဲ့ Column အသစ် (Calculated Column) ထည့်ရပါမယ်။

FactSales table

enter image description here

Discounts table

enter image description here

DiscountKey ကို Calculated Column အနေနဲ့ Table နှစ်ခုလုံးမှာ ထည့်ပြီးပြီ ဆိုရင် ဒီ column ကို အခြေပြုပြီး table နှစ်ခုကို ချိတ်လို့ ရပြီ ဖြစ်တဲ့အတွက် Product Orders တွေပြတဲ့ အချိန်မှာ discount ကို ထည့်ပြလို့ ရသွားပြီ ဖြစ်ပါတယ်။

enter image description here

နည်းလမ်း ၂။ တကယ်လို့ relationship အနေနဲ့ မချိတ်ချင်ဘူး ဆိုရင်တော့ discount table က column value ကို lookup function သုံးပြီ: sales table ထဲကို ခေါ်ထည့်တဲ့ denomalization method ကို သုံးရပါမယ်။

FactSales table

enter image description here

ဒီ Calculated column ကို Sales ထဲမှာ ထည့်မယ်ဆိုရင် Discounts table နဲ့ relation ချိတ်စရာမလိုပဲ discount ကို Sales table ထဲကို de-normalized လုပ်ပြီး ရယူနိုင်မှာပါ။

အခု ပြောခဲ့တဲ့ နည်းလမ်း နှစ်ခုထဲက ဘယ်နည်းလမ်း သုံးသင့်သလဲ ဆိုတာကတော့ factors မျိုးစုံကို ထည့်စဉ်းစားရပါမယ်။

Discounts table ထဲက discount ဆိုတဲ့ column တစ်ခုလောက်ကိုပဲ ခေါ်ထည့်ချင်တာမျိုးဆိုရင်တော့ lookup value formula ကို သုံးတာက ပိုသင့်တော်ပါတယ်။ composite key နဲ့ relation သုံးမယ်ဆိုရင်တော့ different value ဖြစ်နေမဲ့ calculated column နှစ်ခုကို ချိတ်တာ ဖြစ်တဲ့ အတွက် performance မှာ အားနည်းနိုင်ပါတယ်။

တကယ်လို့ ချိတ်ဆက်မဲ့ table ထဲက column တစ်ခုထက်မက ကို ဆွဲခေါ်တွက်ချင်တယ်ဆိုရင်တော့ lookup value formula သုံးမယ်ဆိုရင် ဒီဖက် table မှာ de-normalized columns တွေများနေမှာ ဖြစ်တဲ့ အတွက် Memory waste ဖြစ်ပြီး performance ကို ထိခိုက်နိုင်ပါတယ်။ ဒီအချိန်မှာ ဆိုရင်တော့ composite key ကို သုံးပြီး relation ချိတ်တဲ့ scenario ကို သုံးတာ ပိုပြီး သင့်တော်ပါတယ်။