Create
Goal
The create
Work Tasks is well suited to all cases where you have the database table structure, but you do not have the table data.
- In test and development environments it is often necessary to work with test data for developing and testing different scenarios. With create TABLE, you can insert rows into database tables with sample data and also create records for child tables that are linked together by foreign keys.
Considerations
- When populating a specific database table, all columns must be populated by rules at the same time (else they remain
null
).- As such, it requires more ANO to write
create
tasks thanupdate
tasks, asupdates
needs only rules for certain columns.
- As such, it requires more ANO to write
- It is important to define the creation of data for parent tables before defining the creation of data for child tables, and then ensure that the relation via the foreign keys are defined using
distribute
.- You can specify the distribution of foreign keys used in child records by specifying one of the various distribution algorithms supplied, or you can create a customized distribution for your own purposes. If a parent table is referenced by many child foreign keys, a distribution algorithm may be defined for a group of child tables.
- The minimum-rows value ensures that the table will have at least minimum-rows records inserted.
Work Task create
in Ano
In create
Work Tasks, you can only use the mask
rule strategy. New data is created using input sources of various kinds.
Visit the rules section for more information on how to write create
task rules.
- Structure
- Create Address Example
task <TaskGroupName>
{
create <table> <WorkTaskName> minimum-rows <minimum-rows>
mask <column> <RuleName>
<rule-logic>
mask <column> <RuleName>
<rule-logic>
mask <column> <RuleName>
<rule-logic>
}
table Address
column integer addressNo
column text homeAddress
size 50
column text postalCode
size 10
column datetime created
primary-key addressNo
// - - - - Tasks and Rules - - - - //
task CreateTasks
{
create Address CreateAddressRows minimum-rows 1000
mask addressNo
format %d%d
unique
random-integer 10001000 99909990
random-integer 10001000 99909990
mask homeAddress UpdateAddressUsingFile
format %s
file src/main/resources/addresses.txt random-order
mask postalCode UpdateToRandomPostalCodeAsString
format "%d"
random-integer 1000 9999
mask created
format "%1$tF %1$tT"
random-datetime 2020-01-01 07:00:00 2020-12-31 22:00:00
}