နားလည်ထားရမယ့် အချက်
SQLite ဆိုတာ embedded relational database တစ်ခုပါ - server process သီးခြား မဟုတ်ဘဲ application ထဲကို link လုပ်ထားတဲ့ library တစ်ခုအနေနှင့် disk ပေါ်က file တစ်ခုကို ဖတ်/ရေးပါတယ်။
Application
Application code က SQLite library ကို ခေါ်ပါတယ်
SQLite Library
Application process ထဲမှာပဲ run ပြီး query တွေကို ကိုင်တွယ်ပါတယ်
Database File
Disk ပေါ်က ordinary file တစ်ခုကို တိုက်ရိုက် ဖတ်/ရေးပါတယ် - server မလိုပါ
- Mobile app local storage
- Desktop application
- Command-line tool ငယ်များ
- Local development / automated test
- Edge / offline-first scenario
PostgreSQL/MySQL လို server database ကတော့ ကိုယ်ပိုင် long-lived process အနေနှင့် run ပြီး applications တွေက client အနေနှင့် network ကတစ်ဆင့် ချိတ်ဆက်ပါတယ် - multi-user, production-scale workload အတွက် ဆောက်ထားပါတယ်။
Absolute claim ကို ရှောင်ပါ
"SQLite က real workload တွေကို မကိုင်တွယ်နိုင်ဘူး" လို့ မပြောပါနှင့် - modern SQLite architecture တွေက genuinely sophisticated ဖြစ်လာခဲ့ပါတယ်၊ ရွေးချယ်မှုက concurrency/deployment လိုအပ်ချက်ပေါ်သာ မူတည်ပါတယ်။
- Embedded Database
- Application ထဲကို library အနေနှင့် တိုက်ရိုက် link လုပ်ထားပြီး၊ သီးခြား server process မလိုဘဲ same process ထဲမှာပဲ data ကို ဖတ်/ရေးသည့် database တစ်မျိုး။
EMBEDDED VS SERVER DATABASE MODEL
---------------------------------
EMBEDDED (SQLite)
Application -> SQLite Library -> Database File
(in-process, single file, no server)
SERVER (PostgreSQL / MySQL)
Application -> Network -> Database Server -> Disk
(separate process, many clients connect)လက်တွေ့ scenario နဲ့ ချိတ်ကြည့်မယ်
Application ကိုယ်တိုင်ကသာ local storage ပိုင်ဆိုင်ပြီး တစ်ချိန်တည်း concurrent access မလိုအပ်ရင် SQLite ကို ရွေးပါ - mobile local cache, desktop setting, ဒါမှမဟုတ် test suite တစ်ခုမျိုးမှာပါ။
Independent application/service/user များစွာက network ကတစ်ဆင့် data တစ်ခုတည်းကို concurrent ဖတ်/ရေးဖို့ လိုအပ်ရင် PostgreSQL/MySQL လို server database ကို ရွေးပါ။
Project တချို့က ကြားအလယ်မှာ ရှိတတ်ပါတယ် - SQLite နှင့် စတင်ပြီး concurrent access တကယ်လိုအပ်လာမှသာ migrate လုပ်တာလည်း ရပါတယ်။
အောက်က runnable ဥပမာက application need ကို ယူပြီး embedded ဒါမှမဟုတ် server-based starting point ကို အကြံပြုပါတယ်။
အတူတူ စမ်းရေးကြည့်မယ်
function suggestDatabaseArchitecture(profile) {
const {
isMobileOrDesktopApp,
needsMultipleConcurrentWriters,
needsNetworkAccess,
isSimpleLocalTool,
} = profile;
if (needsMultipleConcurrentWriters || needsNetworkAccess) {
return "Server-based database (e.g., PostgreSQL/MySQL) - a reasonable starting point.";
}
if (isMobileOrDesktopApp || isSimpleLocalTool) {
return "Embedded database (e.g., SQLite) - a reasonable starting point.";
}
return "Depends on further requirements - consider concurrency and deployment model.";
}
console.log("Mobile note-taking app:", suggestDatabaseArchitecture({
isMobileOrDesktopApp: true, needsMultipleConcurrentWriters: false,
needsNetworkAccess: false, isSimpleLocalTool: false,
}));
console.log("Multi-user SaaS backend:", suggestDatabaseArchitecture({
isMobileOrDesktopApp: false, needsMultipleConcurrentWriters: true,
needsNetworkAccess: true, isSimpleLocalTool: false,
}));
console.log("Local CLI test fixture:", suggestDatabaseArchitecture({
isMobileOrDesktopApp: false, needsMultipleConcurrentWriters: false,
needsNetworkAccess: false, isSimpleLocalTool: true,
}));Mobile note-taking app: Embedded database (e.g., SQLite) - a reasonable starting point.
Multi-user SaaS backend: Server-based database (e.g., PostgreSQL/MySQL) - a reasonable starting point.
Local CLI test fixture: Embedded database (e.g., SQLite) - a reasonable starting point.
Mobile app နှင့် local test fixture နှစ်ခုစလုံးက embedded အဖြေရသလို၊ concurrent writer/network access လိုအပ်တဲ့ SaaS backend ကတော့ server-based အဖြေရပါတယ်။၅ မိနစ် စမ်းကြည့်
suggestDatabaseArchitecture ကို isReadHeavyAnalytics flag တစ်ခု ထပ်ထည့်ပြီး၊ true ဖြစ်ရင် server-based database ကို အကြံပြုအောင် ချဲ့ကြည့်ပါ။
သတိလေးတစ်ချက်
"SQLite က real workload မကိုင်တွယ်နိုင်ဘူး" လို့ blanket rule အဖြစ် ယုံကြည်ခြင်း
Multiple process/machine က data တစ်ခုတည်းကို concurrent ရေးရမယ့်အခါမှာပါ SQLite ကို ရွေးချယ်ခြင်း
SQLite: About SQLite — How Databases Work