Generate 10 Customers with 5 Orders each
So far we have just generated data for one table. One of the most powerful features of the TurboData Test Data Generator is the ease in which you can set foreign keys to create parent/child/grandchild test data. This example will show you how to create 10 Customers with 5 Orders each. The foreign key on each Order will be set to the appropriate Customer Id.
In summary, this example will create:
- 10 Customers (numbered 1 to 10)
- 50 Orders (5 for each Customer, numbered 1 to 5)
To create the data execute the following Steps
- Close all dialogs to return to the TurboData primary window.
- Press the Insert Data tab.
- From the Scenario menu, select the New Scenario option.
- Enter the Name '10 Customers with 5 Orders', and press OK.
- The Edit Insert Scenario dialog will be opened automatically. Click on the 'Order' table, keep the mouse button down, and drag the arrow icon over to the right hand tree. Release the mouse button.

- Click on the Order table that you now see in the right tree to give it focus.
- Enter '1' in the Start Range, and '5' in the End Range
- Press the Set Foreign Keys push button. This will open the Set Foreign Keys dialog.

- On the diagram click on the Customer box to select it.
- Set the Parent Table Start Range to '1' and the Parent Table End Range to '10'
- Select the option Yes - Parent data will be generated in this scenario.
- Enter the data to Generate '5' Orders for each Customer
- Press the Close push button. The foreign keys are now set up correctly.
- On returning to the Edit Insert Data dialog you will see that the Customer table has been added to the list of tables for the creation of test data. You can move the Customer to the top to control the order in which the data is generated. To move a table, drag and drop it to a table that you want to position it above.

- Press the Generate push button to open the Generate SQL dialog

- Click on the Update Database option
- Press the Generate push button to Generate the data and automatically load it on to the target database.
- Press the View Data on Target DB push button to open the Edit Data dialog. If you examine the identifiers and the foreign keys you will see that 10 new Customers have been created with 5 Orders each.

Figure 0.2 Each new Customer has 5 Orders