Graph Databases

Graph Database ဆိုတာကတော့ ပုံမှန် database တွေလို row တွေ document တွေနဲ့မဟုတ်ဘဲ data တွေကို node တွေနဲ့ ခွဲပြီး သိမ်းထားတာမျိုးပါ။ database ချိတ်ဆက်ပုံကို ကြည့်လိုက်ရင် တခြား database တွေလို row တွေနဲ့ မဟုတ်ဘဲ graph လိုမျိုး node တွေ ချိတ်ဆက်ထားတာကို တွေ့နိုင်မှာ ဖြစ်ပါတယ်။

Node ဆိုတာကတော့ ကျွန်တော်တို့ရဲ့ system data domain ထဲမှာ ပါဝင်မယ့် entity တခုကို ကိုယ်စားပြုပါတယ်။ ဥပမာ Company data domain မှာဆိုရင် Employee, Department စသဖြင့် node တွေပါဝင်ပါလိမ့်မယ်။ Node တခုဟာ Employee တစ်ယောက်၊ Department တခု စသဖြင့်ကို ကိုယ်စားပြုပါတယ်။

Node တွေမှာ ဘာ node လဲဆိုတာကို သတ်မှတ်ဖို့ရာ Label ဆိုပြီးရှိပါတယ်။ Node တခုချင်းဆီက ဘာ node တွေလဲဆိုတာ ခွဲခြား သိနိုင်ဖို့ရာ Label တွေကို အသုံးပြုပြီး ခွဲပါတယ်။ Node တခုမှာ Label တခုထက်လဲ ပိုပြီးတော့ ရှိနိုင်ပါတယ်။ အပေါ်မှာ ပြောခဲ့တဲ့ Employee, Department တွေဟာ node တွေရဲ့ label တွေပဲ ဖြစ်ပါတယ်။

Node တခုနဲ့တခုဟာလဲ လိုအပ်သလို ချိတ်ဆက်မှုတွေ လုပ်လို့ရပါတယ်။ ဒီလိုချိတ်ဆက်မှုတွေကိုတော့ relationship လို့ခေါ်ပါတယ်။

Relationship တွေသတ်မှတ်တဲ့နေရာမှာ Node တခုနဲ့တခု ဆက်နွယ်ပုံပေါ်မူတည်ပြီး direction ကိုပါ ထည့်ပြီး သတ်မှတ်ပါတယ်။ မြှားဦး ရှိတဲ့ဘက်ကို Target Node လို့ခေါ်ပြီး မြှားဦးမရှိတဲ့ဘက်ကို Start Node လို့ခေါ်ပါတယ်။ Direction အပြင် type ကိုလဲ ထည့်ပြီး သတ်မှတ်လေ့ရှိပါတယ်။ သူကတော့ node ၂ခုကြား ဘယ်လို ဆက်သွယ်မှု ရှိသလဲကို ဖော်ပြပါတယ်။ ဥပမာ Employee တစ်ယောက်နဲ့ Department တခုကြားက relation ကို ဖော်ပြတဲ့အခါ relationship မြှားဦးဟာ employee ဘက်ကနေ department ဘက်ကို သွားမှာ ဖြစ်ပြီးတော့ type ကတော့ belongs_to ဆိုပြီး သတ်မှတ်ထားတာမျိုးပဲ ဖြစ်ပါတယ်။

အစမှာ ပြောခဲ့သလိုပဲ node တခုဟာ entity တခုကို ကိုယ်စားပြုတာဖြစ်တဲ့အတွက် အဲ့ဒီ့ entity ရဲ့ အချက်အလက်တွေကိုပါ node နဲ့အတူ မှတ်ထားဖို့လိုလာပါပြီ။ ဒါတွေကိုတော့ properties လို့ခေါ်ပြီးတော့ key-value structure မျိုးနဲ့ သတ်မှတ်ထားလေ့ရှိပါတယ်။

အပေါ်မှာပြထားတဲ့ graph မှာတော့ node ၂ခုပါဝင်ပါတယ်။ အပေါ်က Node တခုကတော့ Employee ဆိုတဲ့ Label ရှိပြီးတော့ အောက်ကတခုကတော့ Employee နဲ့ Manager ဆိုတဲ့ label တွေရှိပါတယ်။ Node တခုချင်းစီမှာ Name, Role, Join Date ဆိုတဲ့ properties တွေပါဝင်ပါတယ်။ Relationship အနေနဲ့ကတော့ Jane Doe က John Doe ရဲ့ Manager ဖြစ်ပြီးတော့ report လုပ်ရတဲ့ ချိတ်ဆက်မှုမျိုးကို ကိုယ်စားပြုပါတယ်။