Support > Repository > Model item > Database details

Model items are associated with columns (columns) of tables in the database. You can set this details.

You can specify "model item detail definition> details> database details".

Figure 1 Model item detailed definition

It is enabled by standard.In this case, a column (column) is created in the table corresponding to the model.
When this setting is invalid, no columns are prepared in the table.

It can be used when it is not necessary to save it in the database as an item derived by calculation.

Please note: Items that are not saved in the database are constrained to "can not be used as search items" or "can not be used as sort items".Also, when applied to list view or summary view (because it is always recalculated) it contributes to performance degradation.

Wagby automatically creates an index (for the table) that matches the following conditions.

Issue the CREATE INDEX ... command for the database.The timing of issuing is when initial data is read to the external database (init_db.bat file execution).In this case, create an index as well as creating the table.

  • It is stored in the database.
  • It is designated as a search item.
  • It is numeric or date type.
  • For string type, exact match search is specified.Also, it is not a text area.
  • This is the key storage part of the model reference item.However, check boxes are excluded.

By disabling this setting, creation of indexes is suppressed.

"Integer type" and "string type" specified in the repository are automatically converted to each type prepared by each database.

For example, when using MySQL, the string type is treated as varchar (255).

You can specify this type in detail.Figure 2 shows an example of changing the type of table definition to varchar (1024) for string type items.

Figure 2 Specifying the type
There is no character string type size limit for the built-in database used for development.However, the database used in the production environment specifies the size of the string type.To store a long sentence, set this size separately, or use a text area for example.
When reusing the table definition of an existing system with Wagby, please post the type information of the table definition side to this column.

In the model reference item, if the primary key of the referenced model specifies the type of the table definition, check "Apply the same settings as the table definition type of the referenced item".

Figure 3 Applies the same settings as the table definition type in the referenced item

This setting can be checked only when this item is model reference.If checked, "Type of table definition" can not be entered.(This setting takes precedence.)

Normally, the "item ID" (in English) of the model item is used as the column name of the table.You can change this behavior by specifying "physical column name".

Figure 3 Specifying the physical column name
When reusing the table definition of an existing system with Wagby, please post the column name of the table definition side to this column.

In case of composite key model reference7.9.1

Physical column names can be specified arbitrarily in other model reference items that refer to a compound key model.

In the entry column of the physical column name item, enter the physical column name (s), separated by commas.

If you set a unique constraint, you can not register the same data duplicately.As shown in Figure 4, specify the constraint name.

Figure 4 Specifying a unique constraint

Combination of multiple items

You can also set unique constraints combining multiple items.Figures 5 and 6 are constrained to be unique with two names "name" and "name".in this waySame constraint nameTo each item.

Figure 5 Unique constraint specified in the name field
Figure 6 Unique constraint specified in the name field

Behavioral differences by database

The behavior when saving part of the items for which unique constraint settings have been made as unentered (null) depends on the database.

Define unique constraints for fields A, B, and C.Here, we will register the data A: aaa, B: null, C: ccc. After that, if you try to register data of A: aaa, B: null, C: ccc again, it becomes as follows.

Built-in database (HSQLDB), PostgreSQL
Can be registered.
Failure to register due to unique constraint violation.

For details, please read the manual of your database.

Generated DDL7.9

The setting of the unique constraint specified here can be confirmed with the following file.


You can check the contents of the file with a text editor.The following DDL is included.

alter table "モデルID"
   add constraint jfcuk_モデルID_設定した名前 unique ("項目名");

When you run init_db.bat, this alter statement is also executed at the same time.

Automatic adjustment of unique constraint name7.9

The unique constraint name is adjusted according to the maximum length of the constraint name permitted by the database to be used.

Specifically, if the name exceeds the maximum length, it will be abbreviated.(As a result of abbreviation, in case of duplication, assign a unique name so as not to duplicate this.This also applies to table names and item names.)

You can change the rules of lock keys managed internally by Wagby.Normally, this setting is not performed.

Please read "Lock key" for details.

Please read "Business Logic> Cross-Model Calculation (Transaction)".