dim_time
PK time_keydate · month · quarter1DATA SYSTEMS · INTERACTIVE LAB
คำถามที่มีประโยชน์ไม่ใช่ “ฐานข้อมูลใดชนะ” แต่คือระบบหลีกเลี่ยง เลื่อนเวลา จัดเก็บ หรือทำงานส่วนใดซ้ำ
สไลด์ประกอบการเรียน · 34 หน้า
เริ่มจากภาพรวมเชิงแนวคิดก่อนลงมือทำ Lab ตั้งแต่ VIEW, materialization, row กับ column storage, incremental view maintenance ไปจนถึงการเลือกตำแหน่งคำนวณใน modern OLAP
CONCEPTUAL ER DIAGRAM
แต่ละ dimension ใช้อธิบายเหตุการณ์ขายได้หลายรายการ ส่วน Lab ตั้งใจฝัง attribute เหล่านี้ไว้ใน sales เพื่อให้ทั้งสาม engine ได้รับ physical contract เดียวกันที่เคลื่อนย้ายได้ง่าย
PK time_keydate · month · quarter1PK product_keycategory · product1PK customer_idคุณลักษณะลูกค้า1PK geography_keyregion · province1PK channel_keychannel1PK sale_idFK time · product · customerFK geography · channelquantity · unit_price · discountrevenue · cost · profitNONE QUESTION · THREE COMPUTATION PLACEMENTS
สาม LAB · ความต้องการสามแบบ
COMMON DATA CONTRACT
การเปรียบเทียบที่เป็นธรรมต้องมากกว่าการตั้งชื่อคอลัมน์ให้คล้ายกัน ทุก engine จึงได้รับความหมายต่อแถว ค่าแบบ deterministic ตัววัด และโจทย์วิเคราะห์เดียวกัน โดยเปลี่ยนชนิดจัดเก็บเฉพาะส่วนที่ต้องใช้ native type ของ engine นั้น
sale_id · BIGINT / UInt64sale_timestamp · TIMESTAMP / DateTimeregion · provincecategory · productchannel · customer_idquantity · unit_price · discountrevenue · cost · profitregion, category และ channel มีความหมายเดียวกันทุก Lab จึงไม่ทำให้ผลเร็วขึ้นด้วยการแอบเปลี่ยนโจทย์
baseline เดียวกันจัดกลุ่มตาม region และ category แล้วคำนวณจำนวนรายการกับรายได้ จากนั้นจึงใช้การทดลองเฉพาะ engine เพื่อเห็นจุดแข็งจริง
ไม่ใช้ข้อมูลนักศึกษาหรือ production สูตร deterministic ทำให้ reset แล้วสร้างซ้ำได้
schema นี้ตั้งใจให้กระชับเพื่อการสอน ไม่ใช่ enterprise model ฉบับเต็ม ในระบบจริง customer, product และ geography มักแยกเป็น dimension ที่มีการกำกับประวัติ คุณภาพ และความเป็นส่วนตัวอย่างชัดเจน
MASTER COMPARISON
| System | Computation location | Physical reuse | Freshness model | Best teaching question |
|---|---|---|---|---|
| PostgreSQL | database server | materialized rows | explicit refresh | logic vs stored result |
| DuckDB | web process | Parquet + local table | file/table replacement | serverless analytical scan |
| ClickHouse | isolated OLAP server | sorted column parts + aggregate states | new inserted blocks | layout and incremental work |