နားလည်ထားရမယ့် အချက်
Table ဆိုတာ တူညီတဲ့အရာတွေကို ဖွဲ့စည်းဖို့ framework-neutral shape တစ်ခုပါ: entry တစ်ခုစီမှာ ဘာ information ရှိရမလဲ သတ်မှတ်ပေးတဲ့ column တွေ ရှိပြီး၊ entry အမှန်တကယ်တစ်ခုစီဖြစ်တဲ့ row တွေ ရှိပါတယ်။ id, name, email ပါတဲ့ users table တစ်ခုကို စဉ်းစားကြည့်ပါ။
- integer — whole number (id)
- text/string — name, email
- boolean — true/false flag
- date/time — timestamp
- decimal/numeric — price လို fraction လိုအပ်တဲ့ value
- JSON — flexible nested data (တစ်ခါတစ်ရံ)
Row တစ်ခုက အဲဒီအရာရဲ့ instance တစ်ခုကို ကိုယ်စားပြုပါတယ် — user တစ်ယောက်ပါ။ User သုံးယောက်ရှိရင် table မှာ row သုံးကြောင်းရှိပြီး row တစ်ကြောင်းစီမှာ column တိုင်းအတွက် value ရှိရပါတယ်။
Universal Rule မဟုတ်ပါ
'row တစ်ကြောင်း = record တစ်ခု' ဆိုတာ relational, table-based shape အတွက်သာ အလုပ်လုပ်ပါတယ်။ NoSQL data model တချို့က fixed columnar shape လုံးဝမပါဘဲ information ကို ကွဲပြားစွာ group ချကြပါတယ်။
ဒီ lesson က conceptual level မှာသာ ရှိပါတယ် — table, row, column ကို shape အနေနဲ့ မှတ်မိအောင် သင်ပေးတာပါ။ CREATE TABLE syntax ကို ဒီ platform ရဲ့ SQL course မှာ လေ့လာနိုင်ပါတယ်။
- Table
- row နဲ့ column ဖွဲ့စည်းထားတဲ့ similar entry တွေရဲ့ collection တစ်ခု
- Column
- table ထဲက row တိုင်းရှိရမယ့် attribute တစ်ခုနဲ့ data type ကို သတ်မှတ်ပေးတဲ့ field
- Row
- table ထဲက entry/record အမှန်တကယ်တစ်ခု, column တိုင်းအတွက် value ပါဝင်တယ်
THE USERS TABLE
---------------
THE USERS TABLE
-----------------
Column Column Column
| | |
v v v
+------+------------+------------------+
| id | name | email |
+------+------------+------------------+
Row -> | 1 | Thida | thida@example.com|
Row -> | 2 | Kyaw | kyaw@example.com |
Row -> | 3 | Su Su | susu@example.com |
+------+------------+------------------+လက်တွေ့ scenario နဲ့ ချိတ်ကြည့်မယ်
app တစ်ခုမှာ list-shaped screen တွေကို ကြည့်တဲ့အခါ — order table, product grid, admin panel user list — database technology ဘယ်ဟာ တည်ဆောက်ထားပါစေ table/row/column shape ကို ကြည့်နေတာ များပါတယ်။
အသုံးဝင်တဲ့ habit: feature တစ်ခု design မလုပ်ခင် data ကို paper ပေါ်မှာ table အနေနဲ့ ရေးဆွဲကြည့်ပါ။ column name တွေရေးပြီး example row နှစ်ကြောင်းလောက် ဖြည့်ကြည့်ပါ — ဖြည့်လို့မရရင် shape ကို ပြန်စဉ်းစားသင့်ပါတယ်။
SQL Course ကို ပိုလွယ်စေမယ်
Column type ကို eye ခြင်း infer လုပ်တတ်တဲ့ instinct က SQL course ရဲ့ CREATE TABLE syntax ကို brand-new idea မဟုတ်ဘဲ formality တစ်ခုလိုပဲ ခံစားရစေမှာပါ။
အတူတူ စမ်းရေးကြည့်မယ်
function inferType(value) {
if (value === null) return "null";
if (typeof value === "boolean") return "boolean";
if (typeof value === "number") return Number.isInteger(value) ? "integer" : "decimal";
if (typeof value === "string") {
return /^\d{4}-\d{2}-\d{2}/.test(value) ? "date" : "text";
}
if (typeof value === "object") return "json";
return "unknown";
}
function inferColumnTypes(rows) {
const seenTypes = {};
for (const row of rows) {
for (const [column, value] of Object.entries(row)) {
if (!seenTypes[column]) seenTypes[column] = new Set();
seenTypes[column].add(inferType(value));
}
}
const result = {};
for (const [column, types] of Object.entries(seenTypes)) {
result[column] = types.size === 1 ? [...types][0] : [...types].join(" | ");
}
return result;
}
const users = [
{ id: 1, name: "Thida", email: "thida@example.com", is_active: true, joined_at: "2025-01-14", rating: 4.5 },
{ id: 2, name: "Kyaw", email: "kyaw@example.com", is_active: false, joined_at: "2025-03-02", rating: 3.8 },
{ id: 3, name: "Su Su", email: "susu@example.com", is_active: true, joined_at: "2025-06-21", rating: 5 },
];
console.log(inferColumnTypes(users));{
id: 'integer',
name: 'text',
email: 'text',
is_active: 'boolean',
joined_at: 'date',
rating: 'decimal | integer'
}၅ မိနစ် စမ်းကြည့်
inferColumnTypes function ကို သင့် project ရဲ့ real record array (ဥပမာ - order list, product list) နဲ့ run ကြည့်ပြီး ရလဒ်ကို စစ်ဆေးပါ။
သတိလေးတစ်ချက်
data model အားလုံးက fixed row/column ကို သုံးရမယ်လို့ ယူဆခြင်း — NoSQL database တချို့က တမင် ဒီလို မဟုတ်ပါ
column ရဲ့ data type ကို UI ပြသပုံနဲ့ ရောနှောခြင်း (date column က UI မှာ text အဖြစ် ပြသနေလို့ 'text' မဟုတ်ပါ)
Wikipedia: Table (database) — How Databases Work