The Test Database Generator feature helps in creating test databases by either auto-generating simulated data or by subsetting existing data from a source database. It enables users to quickly prepare meaningful datasets for testing without copying large production data.

This feature provides two main options:

- Auto Generate: Automatically generates test data based on the schema of a source database.
- Subsetting: Extracts a smaller dataset from selected anchor tables of an existing database.

## Auto Generate

The Auto Generate option is used to generate a test database with simulated data derived from a source schema. It involves configuration of both Source Database and Target Database details.

### Source DB Configuration

- Database Type: Select the database type from the dropdown. Supported databases include PostgreSQL, MySQL, Oracle, MariaDB, MongoDB, and Cosmos DB.
- URL: Enter the database connection URL of the source database.
- Database Schema Name: Specify the schema name from which the data structure will be used.
- Username: Enter the username to connect to the source database.
- Password: Provide the password for authentication.
- Hints: Add relevant keywords describing the application domain (for example, e-commerce, social media) to help in generating realistic simulated data.

### Target DB Configuration

- URL: Enter the connection URL for the target database.
- Database Schema Name: Provide the schema name where the test data will be generated.
- Username: Enter the username to connect to the target database.
- Password: Enter the corresponding password for authentication.
- Connect Database: Click to validate and establish the connection between source and target databases.

### Generate Records

The Generate Records section allows users to define how many simulated records should be created and how they should be inserted into the target database.

- No of Records: Select the number of records to be generated in the target database. Users can choose the desired count from the dropdown list.
- Insert Mode: Defines how the generated data will be inserted into the database.
  - Auto Insert (Run Immediately): Automatically inserts the generated records into the target database as soon as they are created.
  - Manual Insert (Review & Run Later): Allows users to review the generated data first and then insert it into the target database manually at a later time.

## Subsetting

The Subsetting option is used to extract a smaller dataset from a large source database. It helps in creating lightweight and realistic datasets for testing purposes while maintaining data relationships and consistency.

### Source DB Configuration

- Database Type: Select the type of source database from the dropdown. Supported databases include PostgreSQL, MySQL, Oracle, MariaDB, MongoDB, and Cosmos DB.
- URL: Enter the database connection URL for the source database.
- Database Schema Name: Specify the schema name from which data will be extracted.
- Username: Enter the username to connect to the source database.
- Password: Provide the password for authentication.

### Target DB Configuration

- URL: Enter the connection URL for the target database where the subset data will be stored.
- Database Schema Name: Provide the schema name of the target database.
- Username: Enter the username to connect to the target database.
- Password: Enter the password for authentication.
- Connect Database: Click to establish and validate the connection between the source and target databases.

Note: After filling all the required fields in the Subsetting section, the user needs to click Connect Database. Once the connection is successfully established, the Subsetting From Anchor Tables Configuration section becomes available for further configuration.

### Subsetting From Anchor Tables Configuration

Once the user clicks Connect Database, the Subsetting From Anchor Tables Configuration section opens. This section allows users to configure how data should be subset from the source database.

- Select Records Randomly: Select this option to pick a random set of records from the anchor table.
- Select Specific Records: Choose this option if you want to manually select particular records for subsetting.
- No of Records: Specify the number of records to be extracted for subsetting.

At the bottom of this section, the following actions are available:

- Generate: Initiates the subsetting process based on the selected configurations.
- Reset: Clears the current settings and allows the user to reconfigure subsetting parameters.

### Select Specific Records

This option allows you to extract specific records from the anchor tables based on custom conditions instead of selecting them randomly. You can define filters and limits to refine which records are included in the subset.

#### Key Fields and Options:

- Table Name: Select the table from which you want to extract data. The dropdown lists all available anchor tables.
- Where Clause: Enter a SQL-style WHERE condition to filter records based on specific criteria. Example: age > 30 AND status = 'active'
- Row Limit: Specify the maximum number of records to extract that satisfy the given condition.
- Settings Button: Opens additional configuration options related to data selection and filtering.
- Add Row (+) Icon: Allows you to add multiple selection conditions for different tables or criteria.
- Generate Button: Executes the subset generation process based on the defined conditions and limits.
- Reset Button: Clears all the entered details and restores the screen to its default state.

### Anonymization Settings

The Anonymization Settings option allows you to protect sensitive information during data subsetting. You can define whether to anonymize data automatically or specify which columns should be anonymized manually.

#### Available Options:

- No Anonymization: No data masking is applied. The extracted subset retains original data values.
- Anonymize Auto Detected Personally Identifiable Information: Automatically detects and anonymizes personally identifiable information (PII) such as names, addresses, and contact details.
- Anonymize Specified Columns: (Selected Option) Enables you to manually select specific columns that need to be anonymized. This provides flexibility to protect only relevant data fields.

#### Key Fields and Controls:

- Table Name: Choose the table containing the columns that require anonymization.
- Column: Select the specific column from the chosen table that needs to be anonymized.
- Category: Define the type of data to be anonymized by selecting an appropriate category, such as: First Name, Last Name, Full Name, City, Street Address, Zip Code, Country.
- Add (+) Icon: Allows you to include multiple column entries for anonymization across different tables or data fields.
- Apply Button: Saves and applies the selected anonymization configurations.
- Reset Button: Clears all selected values and resets the screen to its initial state.

### Restrict Association Table

The Restrict Association Table option is used to define and control how associations between database tables are handled during the subsetting process. It helps to restrict data relationships (both forward and inverse) to maintain data integrity and ensure that only relevant linked records are included in the subset.

#### Key Components:

- Source Table: Displays the name of the primary (or parent) table from which associations originate.
- Associated Table: Shows the related (or child) table linked through a foreign key relationship.
- Key: Indicates the foreign key used to establish the relationship between the source and associated tables.
- Restrict Forward Association: When checked, it prevents data from being fetched from associated (child) tables in the forward direction of the relationship.
- Restrict Inverse Association: When selected, it restricts fetching of data from parent tables that are linked inversely through the relationship key.

### Global Action Icons

At the top-right of the Restrict Association Table window, several quick-access icons are available to help manage and export the displayed data efficiently:

- Search: Search specific source or associated tables within the list.
- Column Filter: Filter displayed columns to view only relevant associations.
- Manage Columns: Show or hide specific columns to customize the table view.
- Download Options: User can export the data in Word, PDF, Excel, or CSV formats.

#### Actions and Buttons:

- Reset: Clears all current selections and restores the default configuration.
- Customize and Save: Saves the modified restriction preferences for future use during data subsetting.