Skip to main content

Creating and operating Database Table Data Sets

7 Tasks

20 mins

Visible to: All users
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.

 

You must initiate your own Pega instance to complete this Challenge.

Initialization may take up to 5 minutes so please be patient.

Challenge Walkthrough

Detailed Tasks

1 Create a new Database table Data Set

  1. Log in as the System Architect:
    1. In the User name field, enter SystemArchitect.
    2. In the Password field, enter rules.
  2. In the navigation pane of Dev Studio, click App to open the Application Explorer.
  3. In the Application Explorer, search for the Sample-Data-Colors class.
  4. In the Application Explorer, right-click on the Sample-Data-Colors class, then select Create > Data Model > Data Set.
  5. On the Create Data Set tab, create a new Data Set:
    1. In the Label field, enter Colors.
    2. In the Type list, confirm that Database Table is the default selection.
    3. In the upper-right corner, click Create and open to open the Data Set.
      The creation of the Colors Data Set
    4. On the Data set: Colors tab, in the upper-right corner, click Save.
      The Database table tab
      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

  1. On the Data set: Colors tab, in the upper-right corner, click Actions > Run.
  2. In the Run Data Set: Colors window, view the data:
    1. In the run context, in the Operation list, select Browse.
    2. In the upper-right corner of the run context, click Run to view the run results.
    3. Browse through the results.
      The run results of the Colors Data Set
    4. Close the Data Set Preview window.

3 Export the data in JSON format

  1. 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.
  2. In the Export data set window, click Export, and then click Download file to save the file on your local drive.
  3. In the file explorer, open the ZIP file to review the file contents in the data.json file by using any text editor.
    The JSON data in a text editor
  4. 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

  1. On the Data set: Colors tab, in the upper-right corner, click Actions > Run.
  2. In the Run Data Set: Colors window, truncate the data:
    1. In the run context, in the Operation list, select Truncate.
    2. In the upper-right corner of the run context, click Run to truncate all records.
    3. Close the Status Page window.
    4. In the run context, in the Operation list, select Browse.
    5. In the upper-right corner of the run context, click Run to view the run results.
    6. Confirm that there are no records.
    7. Close the Data Set Preview window.
    8. Close the Run Data Set: Colors window.

5 Import the data in the database table

  1. On the Data set: Colors tab, in the upper-right corner, click Actions > Import to import the data.
    1. In the Import Data Set dialog box, click Choose File, and then select the ZIP file that you downloaded in Task 3.
      The Import data set dialog box
    2. Click Import.
    3. Click Done.
  2. On the Data set: Colors tab, in the upper-right corner, click Actions > Run.
  3. In the run context, in the Operation list, select Browse to view the import:
    1. In the upper-right corner of the run context, click Run to view the run results.
    2. Confirm that data is imported.
      The Data Set Preview window
    3. Close the Data Set Preview window.
    4. Close the Run Data Set: Colors window.

6 Preview the data for a specific key

  1. On the Data set: Colors tab, in the upper-right corner, click Actions > Run.
  2. In the Run Data Set: Colors window, preview the data:
    1. In the run context, in the Operation list, select Browse by keys.
    2. In the Key list, select ColorID.
    3. In the Value field, enter Color-1.
    4. In the upper-right corner of the run context, click Run to view the run results.
      The Run Data Set Colors window
    5. In the Data Set Preview window, note that only one record is shown.
      The results of the Data Set preview
    6. Close the Data Set Preview window.
    7. Close the Run Data Set: Colors window.

7 Delete a record using a specific key

  1. On the Data set: Colors tab, in the upper-right corner, click Actions > Run.
  2. In the Run Data Set: Colors window, .
    1. In the run context, in the Operation list, select Delete by keys.
    2. In the Key list, select ColorID.
    3. In the Value field, enter Color-1.
    4. In the upper-right corner of the run context, click Run, and then close the Status Page window.
  3. In the run context, in the Operation list, select Browse to view the data:
    1. In the upper-right corner of the run context, click Run to view the run results.
    2. Confirm that Color-1 is deleted and that six records remain.
    3. Close the Data Set Preview window.
    4. 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.

Did you find this content helpful?

Want to help us improve this content?

We'd prefer it if you saw us at our best.

Pega Academy has detected you are using a browser which may prevent you from experiencing the site as intended. To improve your experience, please update your browser.

Close Deprecation Notice