We deal with two models "customer" and "support". At this time, we have a relationship that "There is more than one support record for one customer". Parent is customer (1), child is support (N).
Let's take a look at two models, "customer" and "support".
Register new customer's data.
The "Support new creation" button is prepared on the detail display screen of the customer.(Fig. 1) New registration of the support model that is related to the foreign key is done from the detail display screen of the target data (here customer data).
Click the "Create new support" button and open the support new registration screen.The customer ID (ID of the linked parent model) is automatically set.
Enter each item and register."Customer list display" and "Customer details display" button for returning to the customer model from the support detailed display screen are prepared.
Click the "Customer details display" button to open the customer details display screen.A list of support records will be displayed on the customer model side as well.
In this way, models that are related to foreign keys also have bidirectional link relationships on the screen.This will allow you to check "which records were supported by which customers".
The definition of the support model prepared this time is shown in Figure 6.
Specify the type of the item specified as the foreign key with the same type as the type of the reference (parent) item.In this example, "customer ID" is specified as "numeric" type.
The point of definition is the part that specifies that "customer ID" is a foreign key.(FIG. 7)
Specify the parent model for "foreign key> model name".
"Referenced item name" is the item on the child model side isSame nameCan be omitted.(This time it is the same "customerid", so you can omit it.)
When the external key model list display format is grid, the child model display will also be grid.
The grid display has several limitations. For details, please read "Screen function> Search · List display (List display) Grid format".
Foreign key Chain icon is displayed in the model item list for the specified item.
The order of the child model list data prepared at the bottom of the detailed display screen of the parent model is the ascending order of the child model primary key. You can change this.
For example, when creating child data c1, c2, c3 linked to parent p1, the display order of the child model list is c1, c2, c3 by default. If "-1" is specified here in the sort order of the child model "primary key" item, it becomes c 3, c 2, c 1.
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.