In Part 2: How to query data from multiple REST endpoints, we guided you through how to query data from multiple REST endpoints using SQL without writing a line of code. However, if you are new to this series, we recommend that you start with Part 1: How to query REST data with JDBC applications.
When sampling REST endpoints, the Autonomous REST Connector heuristically generates a relational schema, including column names and data types that are typically user friendly. However, there can be situations where you might want to rename a table or field name to avoid confusion, change the data type to one that is more appropriate, or change the primary key to a different field. In this tutorial, we will guide you through the process of editing your schema to make these changes.
Before you begin editing your schema, you need to open your REST Model file in the Autonomous REST Composer:
java -jar autorest.jar --design
By default, the autorest.jar file is stored in the following directory: C:\Program Files\Progress\DataDirect\JDBC\lib\60
.
C:\path-to-file\yelp.rest
After sampling your endpoints, you can customize your schema from the default mapping, including modifying the column names, data type mapping, and primary key designation. To demonstrate changing column attributes, we are going to update the ALIAS
column in the CATEGORIES
table with the following changes:
ALIAS
column to the TITLE
column.ALIAS
column CATEGORYCODE
. ALIAS
column data type from VarChar to LongVarCharGET https://api.yelp.com/v3/categories/categories
CATEGORYCODE
.TITLE
column:
You can see your changes in the list of endpoints in the left pane. In the CATEGORIES
table, you can see that ALIAS
has been renamed CATEGORYCODE
and the TITLE
column now has the primary key indicator next to the name. In addition, you can see the foreign key has been updated for the child tables for the categories endpoint. For example, in the COUNTRY_BLACKLIST
table, the foreign key CATEGORIES_ALIAS
has been replaced with CATEGORIES_TITLE
.
As with column names, it may be useful to rename tables if the generated names are confusing or lack real-world context. For example, in the Model file used to sample Yelp endpoints in Part 2, two categories tables were created: CATEGORIES
and CATEGORIES_1
. The first came from the categories endpoint, while the second came from the businesses endpoint. To provide better context, we are going to change the name of the CATEGORIES_1
table to BUSINESS_CATEGORIES
.
To change a table name:
GET https://api.yelp.com/v3/businesses/search
BUSINESS_CATEGORIES
. You can observe that the table name has been updated to BUSINESS_CATEGORIES
in table list in the left pane.
After updating your Model, click Download to generate a Model file that reflects your changes. Then move your file to a directory that can be accessed by the driver. To use the updated Model file with your next connection, specify the fully qualified path to the updated file using the Config property.
In the next tutorial, we will show you how to configure paging using the Autonomous REST Connector.
The Autonomous REST Connector provides JDBC and ODBC connectivity to Jira, GitHub, Azure, and many other REST APIs.