Appearance
05.06 Master Data Design Guidelines
📌 At a Glance
| รายการ | รายละเอียด |
|---|---|
| Topic | Master Data Design Guidelines |
| Difficulty | ⭐⭐ Intermediate |
| Reading Time | 10 นาที |
| Target | Developer, Database Designer, System Integrator |
🎯 Learning Objectives
หลังจากศึกษาหัวข้อนี้แล้ว ผู้อ่านจะสามารถ
- ออกแบบฐานข้อมูลสำหรับเก็บ Master Data ได้
- เข้าใจความสัมพันธ์ระหว่าง Products, Units และ Receivers
- เตรียมฐานข้อมูลสำหรับใช้งานร่วมกับ Order Checking APIs
Overview
SISAHYGO แนะนำให้ Client System จัดเก็บ Master Data ไว้ในฐานข้อมูลของตนเอง เพื่อลดจำนวนการเรียก API เพิ่มความเร็วในการทำงาน และรองรับการทำงานเมื่อการเชื่อมต่อเครือข่ายมีความล่าช้า
Master Data ทั้งหมดควรถูก Synchronize จาก SISAHYGO และไม่ควรแก้ไขข้อมูลอ้างอิงโดยตรงใน Client System
Figure 5-6 Master Data Database Design

Figure 5-6 แสดงตัวอย่างโครงสร้างฐานข้อมูลสำหรับจัดเก็บ Master Data และความสัมพันธ์ระหว่าง Products, Units, Receivers และ Order Checking
Recommended Tables
แนะนำให้สร้างตารางดังนี้
| Table | Description |
|---|---|
| products | ข้อมูลสินค้า |
| units | ข้อมูลหน่วยนับ |
| receivers | ข้อมูลผู้รับสินค้า |
Products Table
| Field | Type | Description |
|---|---|---|
| product_id | PK | รหัสสินค้า |
| product_name | varchar | ชื่อสินค้า |
| unit_id | FK | อ้างอิงตาราง units |
| unit_name | varchar | ชื่อหน่วยนับ |
Units Table
| Field | Type | Description |
|---|---|---|
| unit_id | PK | รหัสหน่วยนับ |
| unit_name | varchar | ชื่อหน่วยนับ |
Receivers Table
| Field | Type | Description |
|---|---|---|
| customer_rec_id | PK | รหัสผู้รับสินค้า |
| to_customer_name | varchar | ชื่อผู้รับ |
| to_customer_phone | varchar | หมายเลขโทรศัพท์ |
| branch_rec_id | integer | รหัสสาขาปลายทาง |
Entity Relationship
text
Units
│
│ unit_id
▼
Products
▲
Order Checking
▼
ReceiversPrimary Key Recommendation
| Table | Primary Key |
|---|---|
| products | product_id |
| units | unit_id |
| receivers | customer_rec_id |
Foreign Key Recommendation
| Parent | Child |
|---|---|
| units.unit_id | products.unit_id |
| products.product_id | order_details.product_id |
| receivers.customer_rec_id | order_headers.customer_rec_id |
Local Database Recommendation
แนะนำให้เก็บข้อมูลดังนี้
text
master_products
master_units
master_receiversเพื่อแยกจาก Transaction Tables
Best Practices
- ใช้ Primary Key จาก SISAHYGO โดยตรง
- ไม่เปลี่ยนค่า ID ภายใน Client System
- ใช้ Foreign Key เพื่อรักษาความถูกต้องของข้อมูล
- Synchronize Master Data ก่อนใช้งานทุกวัน
Implementation Notes
- Units เป็น Global Master
- Products และ Receivers เป็น Customer-specific Master
- ไม่ควรสร้าง Master Data เองในฝั่ง Client
Summary
การออกแบบฐานข้อมูลที่สอดคล้องกับโครงสร้างของ SISAHYGO จะช่วยลดความซับซ้อนของการพัฒนา เพิ่มประสิทธิภาพในการ Synchronize และรองรับการขยายระบบในอนาคต
Next Step
➡️ 05.07 Best Practices
