Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

In this article, we will discuss how to design a many to many form/record relationship based on the sample app.

There are 3 tables needed in total in order to form a many-to-many relationship:-

Thai

ในบทความนี้เราจะหารือถึงวิธีการออกแบบความสัมพันธ์แบบฟอร์ม / บันทึกหลายอย่างขึ้นอยู่กับแอพตัวอย่าง

มีทั้งหมด 3 ตารางที่จำเป็นในการสร้างความสัมพันธ์ many-to-many relationship : -

  • Many2Many_table1
  • Many2Many_table2
  • Many2Many_joiner

where the last table mentioned will act as the junction table.

Thai

โดยที่ตารางสุดท้ายที่กล่าวถึงจะทำหน้าที่เป็นตารางแยก

In this generic sample app, we are treating "Form 1" as ingredients and "Form 2" as a recipe.

The figure below shows the list of recipes.

Thai

ในแอปตัวอย่างทั่วไปนี้เรากำลังรักษา "แบบฟอร์ม 1" เป็นส่วนผสมและ "แบบฟอร์ม 2" เป็นสูตร

รูปด้านล่างแสดงรายการของสูตรอาหาร

The figure below shows the list of ingredients.

Thai

รูปด้านล่างแสดงรายการส่วนผสม

A recipe requires multiple ingredients and an ingredient is used by multiple recipes. The following figure depicts the "joiner" records.

Thai

สูตรต้องการส่วนผสมหลายอย่างและส่วนผสมถูกใช้โดยหลายสูตร รูปต่อไปนี้แสดงให้เห็นถึงบันทึก "ช่างไม้"

And, here's how the joiner table records look like. Observe c_id_form1 and c_id_form2. They are the foreign key to table1 and table2 respectively.

Thai

และนี่คือลักษณะของตารางผู้เข้าร่วมที่มีลักษณะอย่างไร สังเกต c_id_form1 และ c_id_form2 มันเป็น foreign key ไปที่ table1 และ table2 ตามลำดับ

This is table1 data.

Thai

นี่คือข้อมูล table1


This is table2 data.

Thai

นี่คือข้อมูล table2


The app is created using simple select box and form grid. You may study its design by downloading the sample app below.

The figure below shows the design of Form1.

Thai

แอพนี้สร้างขึ้นโดยใช้กล่องเลือกและตารางแบบง่าย คุณสามารถศึกษาการออกแบบได้โดยดาวน์โหลดแอพตัวอย่างด้านล่าง

รูปด้านล่างแสดงการออกแบบของ Form1


Based on the figure below, we can see that Form 1 has:-

Thai

จากรูปด้านล่างเราจะเห็นว่าแบบฟอร์ม 1 มี: -

  1. An ID Generator Field to create a running number as record ID.

    Thai

    เขตข้อมูลตัวสร้าง ID เพื่อสร้างหมายเลขเรียกใช้เป็นรหัสระเบียน

  2. Text Field

    Thai

    ช่องข้อความ

  3. Form Grid to select items from Form 2 to be stored in the joiner table.

    Thai

    Form Grid เพื่อเลือกรายการจากแบบฟอร์ม 2 ที่จะจัดเก็บในตารางช่างไม้

Form 2 has identical form design as per Form 1, as explained below.

In the joiner form, it contains just 2 select boxes.

Thai

แบบฟอร์ม 2 มีการออกแบบฟอร์มเหมือนกันตามแบบฟอร์ม 1 ตามที่อธิบายไว้ด้านล่าง

ในรูปแบบช่างไม้มันมีเพียง 2 กล่องที่เลือก


Each of the select boxes would point to Form 1 and Form 2 using Default Form Options binder as shown in the form structure figure below.

Thai

กล่องที่เลือกแต่ละกล่องจะชี้ไปที่แบบฟอร์ม 1 และแบบฟอร์ม 2 โดยใช้ตัวยึดฟอร์มตัวเลือกเริ่มต้นตามที่แสดงในรูปแบบโครงสร้างด้านล่าง


You may try it out yourself by downloading the sample app below.

Thai

คุณสามารถลองด้วยตัวเองโดยดาวน์โหลดแอปตัวอย่างด้านล่าง

Sample App

Thai

แอปตัวอย่าง

View file
nameAPP_Many2Many-1-20180507154857.jwa
height150