Skip to content

05.06 Master Data Design Guidelines


📌 At a Glance

รายการรายละเอียด
TopicMaster Data Design Guidelines
Difficulty⭐⭐ Intermediate
Reading Time10 นาที
TargetDeveloper, 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

Figure 5-6 แสดงตัวอย่างโครงสร้างฐานข้อมูลสำหรับจัดเก็บ Master Data และความสัมพันธ์ระหว่าง Products, Units, Receivers และ Order Checking


Recommended Tables

แนะนำให้สร้างตารางดังนี้

TableDescription
productsข้อมูลสินค้า
unitsข้อมูลหน่วยนับ
receiversข้อมูลผู้รับสินค้า

Products Table

FieldTypeDescription
product_idPKรหัสสินค้า
product_namevarcharชื่อสินค้า
unit_idFKอ้างอิงตาราง units
unit_namevarcharชื่อหน่วยนับ

Units Table

FieldTypeDescription
unit_idPKรหัสหน่วยนับ
unit_namevarcharชื่อหน่วยนับ

Receivers Table

FieldTypeDescription
customer_rec_idPKรหัสผู้รับสินค้า
to_customer_namevarcharชื่อผู้รับ
to_customer_phonevarcharหมายเลขโทรศัพท์
branch_rec_idintegerรหัสสาขาปลายทาง

Entity Relationship

text
Units

  │ unit_id


Products



Order Checking



Receivers

Primary Key Recommendation

TablePrimary Key
productsproduct_id
unitsunit_id
receiverscustomer_rec_id

Foreign Key Recommendation

ParentChild
units.unit_idproducts.unit_id
products.product_idorder_details.product_id
receivers.customer_rec_idorder_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

SISAHYGO API Integration Guide