Creating and operating Database Table Data Sets
7 Tasks
20 mins
Beginner
Pega Platform '24.2
English
Scenario
In the Sample application, a database table named Colors is available for the exercise. The table contains sample data for colors.
Create a new data base table Data Set and complete the given tasks.
Use the following credentials to log in to the exercise system:
Role | User name | Password |
---|---|---|
System architect | SystemArchitect | rules |
Your assignment consists of the following tasks:
Task 1: Create a new database table Data Set
Create a new database table Data Set in the Sample-Data-Colors class named Colors.
Task 2: Preview the data in the database table
Preview the data in the database table by using the Data Set Browse operation.
Task 3: Export the data in JSON format
Export and download the ZIP file, and then Preview the JSON file contents in any text editor.
Task 4: Truncate the data in the database table
Truncate the records in the database table by using the Data Set Truncate operation.
Task 5: Import the data in the database table
Use the exported ZIP file to import the records back into the database table.
Task 6: Preview the data for a specific key
Browse the data using the ColorID for the Color-1 by using the Browse by keys operation.
Task 7: Delete a record using a specific key
Delete the Color-1 record by using the Delete by keys operation.
Challenge Walkthrough
Detailed Tasks
1 Create a new Database table Data Set
- Log in as the System Architect:
- In the User name field, enter SystemArchitect.
- In the Password field, enter rules.
- In the navigation pane of Dev Studio, click App to open the Application Explorer.
- In the Application Explorer, search for the Sample-Data-Colors class.
- In the Application Explorer, right-click on the Sample-Data-Colors class, then select Create > Data Model > Data Set.
- On the Create Data Set tab, create a new Data Set:
- In the Label field, enter Colors.
- In the Type list, confirm that Database Table is the default selection.
- In the upper-right corner, click Create and open to open the Data Set.
- On the Data set: Colors tab, in the upper-right corner, click Save.
Tip: In this case, the only key in the Selectable keys section is the primary key of the Sample-Data-Colors class, the ColorID. You can add additional keys to a Data Set, and then use that key to browse the data. When you create a new Data Set, the system automatically adds the keys of the primary class as the selectable keys. For abstract classes where a key is not available, you manually select and add the Selectable keys.
2 Preview the data in the database table
- On the Data set: Colors tab, in the upper-right corner, click Actions > Run.
- In the Run Data Set: Colors window, view the data:
- In the run context, in the Operation list, select Browse.
- In the upper-right corner of the run context, click Run to view the run results.
- Browse through the results.
- Close the Data Set Preview window.
3 Export the data in JSON format
- On the Data set: Colors tab, in the upper-right corner, click Actions > Export to download the records in ZIP format to your local drive.
- In the Export data set window, click Export, and then click Download file to save the file on your local drive.
- In the file explorer, open the ZIP file to review the file contents in the data.json file by using any text editor.
- Close the file, and then return to the exercise environment.
Note: You use the ZIP file in the Import the data in the database table task.
4 Truncate the data in the database table
- On the Data set: Colors tab, in the upper-right corner, click Actions > Run.
- In the Run Data Set: Colors window, truncate the data:
- In the run context, in the Operation list, select Truncate.
- In the upper-right corner of the run context, click Run to truncate all records.
- Close the Status Page window.
- In the run context, in the Operation list, select Browse.
- In the upper-right corner of the run context, click Run to view the run results.
- Confirm that there are no records.
- Close the Data Set Preview window.
- Close the Run Data Set: Colors window.
5 Import the data in the database table
- On the Data set: Colors tab, in the upper-right corner, click Actions > Import to import the data.
- In the Import Data Set dialog box, click Choose File, and then select the ZIP file that you downloaded in Task 3.
- Click Import.
- Click Done.
- In the Import Data Set dialog box, click Choose File, and then select the ZIP file that you downloaded in Task 3.
- On the Data set: Colors tab, in the upper-right corner, click Actions > Run.
- In the run context, in the Operation list, select Browse to view the import:
- In the upper-right corner of the run context, click Run to view the run results.
- Confirm that data is imported.
- Close the Data Set Preview window.
- Close the Run Data Set: Colors window.
6 Preview the data for a specific key
- On the Data set: Colors tab, in the upper-right corner, click Actions > Run.
- In the Run Data Set: Colors window, preview the data:
- In the run context, in the Operation list, select Browse by keys.
- In the Key list, select ColorID.
- In the Value field, enter Color-1.
- In the upper-right corner of the run context, click Run to view the run results.
- In the Data Set Preview window, note that only one record is shown.
- Close the Data Set Preview window.
- Close the Run Data Set: Colors window.
7 Delete a record using a specific key
- On the Data set: Colors tab, in the upper-right corner, click Actions > Run.
- In the Run Data Set: Colors window, .
- In the run context, in the Operation list, select Delete by keys.
- In the Key list, select ColorID.
- In the Value field, enter Color-1.
- In the upper-right corner of the run context, click Run, and then close the Status Page window.
- In the run context, in the Operation list, select Browse to view the data:
- In the upper-right corner of the run context, click Run to view the run results.
- Confirm that Color-1 is deleted and that six records remain.
- Close the Data Set Preview window.
- Close the Run Data Set: Colors window.
This Challenge is to practice what you learned in the following Module:
Available in the following mission:
If you are having problems with your training, please review the Pega Academy Support FAQs.
Want to help us improve this content?