How Corticon concepts apply to Datasources
- Last Updated: July 2, 2019
- 2 minute read
- Corticon
- Documentation
Internally, Corticon accesses all data sources using SQL. A Corticon Vocabulary is fundamentally relational in nature, and conceptually equivalent to the elements of a typical relational database:
| Corticon Vocabulary | Relational Database |
|---|---|
| Vocabulary | Schema |
| Vocabulary: Entity | Table |
| Vocabulary: Attribute | Table Column or Field |
| Vocabulary: Association | Relationship between Tables |
| Ruletest Output | Table Row(s) or Record(s) |
How REST can conform to a relational database schema
Corticon uses the Progress® DataDirect® Autonomous Rest Connector to access REST Datasources, which maps the returned JSON to a relational database schema and translates SQL statements to REST API requests. When configuring a REST Datasource you can either have the Autonomous Rest Connector discover the schema for a REST service or provide your own schema file. The schema tells the Autonomous Rest Connector how to map JSON in memory database tables which Corticon will then access with SQL.
JSON data is hierarchical, not relational, but can be mapped to a relational model. When using schema discovery, Autonomous Rest Connector will determine how to perform this mapping. If you need finer control over the mapping, you can provide your own schema file.
The Autonomous Rest Connector handles the complexities of mapping JSON to a relational representation but you need to understand the rules applied to perform the mapping. This is best done by example. Imagine you have a REST service which returned the JSON.{
"applicant": [
{
"name": "Sydney Smith",
"income": 57000,
"address": {
"street": "101 Main Street",
"city": "Raleigh",
"state": "NC"
},
"children": [
{
"name": "Robert Smith",
"dob": "2017-04-19"
},
{
"name": "Chelsea Smith",
"dob": "2014-11-07"
}
]
}
]
}
Looking
at this, you can see there is one applicant, Sydney Smith, with two children and other
information about Sydney. The Autonomous REST Connector would represent this
relationally as two tables, "applicant" and "children". The applicant table would
contain columns for: - name
- income
- street
- city
- state
- name
- dob
In this simple example:
- The applicant and their attributes were added to the applicant table
- The nested address data was "flattened" and made attributes of the applicant
- The nested array of children objects were mapped to an associated table
| Corticon Vocabulary | Relational Database | REST mapping |
|---|---|---|
| Vocabulary | Schema | Schema (even if implicit) |
| Vocabulary: Entity | Table | Object |
| Vocabulary: Attribute | Table Column or Field | Number, string, or null |
| Vocabulary: Association | Relationship between Tables | Array of objects, strings, or numbers |
| Ruletest Output | Table Row(s) or Record(s) | Object Instances |
For an example a schema in a REST Datasource, see Mapping REST Service metadata .