JOIN က table နှစ်ခု သို့မဟုတ် နှစ်ခုထက်ပိုတဲ့ table တွေကို ဆက်စပ် column အပေါ်မူတည်ပြီးပေါင်းဖတ်ဖို့သုံးပါတယ်။ Real database တွေမှာ data အားလုံးကို table တစ်ခုထဲမသိမ်းပါ။ Customer data က Customers table ထဲ၊ Order data က Orders table ထဲသီးသန့်သိမ်းပြီး လိုတဲ့အချိန်မှာ join လုပ်ဖတ်ပါတယ်။
ဘာကြောင့်ခွဲသိမ်းလဲ?
Data duplication လျှော့ချရန်၊ update လုပ်ရလွယ်ရန်၊ relationship သေချာရန်ပါ။ ဥပမာ order တစ်ခုစီမှာ customer name ကိုထပ်သိမ်းမယ့်အစား CustomerID ကိုသိမ်းထားပြီး customer name လိုတဲ့အခါ join လုပ်ယူပါတယ်။
sql
-- Orders table နမူနာ
-- OrderID | CustomerID | OrderDate
-- 10308 | 2 | 1996-09-18
-- 10309 | 3 | 1996-09-19You should see
Important things to notice: Orders.CustomerID က Customers.CustomerID နဲ့ဆက်စပ်နေပါတယ်။ ဒါကြောင့် order ကို customer name နဲ့အတူပြချင်ရင် ဒီ column ကို bridge အဖြစ်သုံးပါတယ်။