Wagby allows you to set parent-child relationships in your model.
Here, when expressing the main model as "parent" and the model dependent on parent as "child", the following relation holds for parent and child.
In this tutorial, you will learn how to set up a parent-child relationship.
We prepare a "support" model which is a child model dependent on this customer model as a parent. Support can be registered multiple times for one customer.
|Item name (Japanese)||Item name (English)||Item type||Primary key||Foreign key|
|Support ID||supportid||Integer type||○|
|Customer ID||customerid||Integer type||○|
|Support type||supporttype||Item reference of another model (list box)|
Create a new model.
We will name the model "support".Suppose the model ID is "support".
Next to the primary key item "support ID", prepare the foreign key item "customer ID".
The item ID is the same as the item ID (customerid) of the customer model.
Type is always the same (numerical type here).
In the detailed setting of customer ID, set the column of foreign key.Designation of the model name is mandatory.
The referenced item name is "It is specified when the item ID's name is different. Since this time it is the same item ID (customerid), designation is unnecessary.(It will be automatically discriminated.)
Define the remaining items.In this case, "support type" is a character string type.(Because the alternative model of the reference has not been created yet)
Prepare a new option model "support type".We also set the initial value.(FIG. 5, FIG. 6, FIG. 7)
Again you will return to the support model edit screen.Change the type of support type to "reference item of other model".(FIG. 8, FIG. 9)
Associate with the support type model prepared in Figure 6.
Indicates the finished model definition.(FIG. 11)
As before, I stop, build, and restart the Web application. After logging on to the application, import historical data.
Opens the detailed display screen of an arbitrary customer model.New "Support new creation" button is prepared.
I will try creating a new support.The customer's primary key (customer ID), which is the parent model, is automatically granted.
On the detailed support screen of the support, buttons for transitioning to the list display / detail display screen for the parent model customer are provided.
In the detail display screen of the customer, N support information related to this is displayed.(1: N relationship)
Both the "repeating container" and the "foreign key" can build a 1: N relationship between the parent model and the child model.The difference between the two is as follows.
In the tutorial so far, the three models "customer", "business daily report" and "support" are linked in different ways.This is shown in Figure 18.
"Frequently asked questions and answers> tutorialPlease read.