Back to main page

API:Schema

Concept

An aito's schema is similar to a SQL's schema. The schema contains the tables' name, columns' name and values' type. It also contains additional meta-information about linking, and the analysis of column values. This is im portant in order for aito to perform well. These meta-information will be further explained in below sect ions. API: Schema is used to manage the schema.

API end point

/api/v1/_schema

Structure

Available operations:

  1. Populate a new schema
  2. Delete an existing schema
  3. Delete an existing table (delete both information from the schema and data content from the database)

aito's schema structure

  1. Example:

     {
       "schema": {
    
         "customers": {
           "type":"table",
           "columns": {
             "id"   : {"type": "Int" },
             "name" : {"type": "String" },
             "tags" : {"type": "Text", "analyzer": "Whitespace" }
           }
         },
    
         "products": {
           "type":"table",
           "columns": {
             "id"          : { "type": "Int" },
             "name"        : { "type": "String" },
             "title"       : { "type": "Text",  "analyzer": "English" },
             "tags"        : { "type": "Text",  "analyzer": "English" },
             "price"       : { "type": "Decimal"},
             "description" : { "type": "Text",  "analyzer": "English" }
           }
         },
    
         "messages": {
           "type":"table",
           "columns": {
             "id"         : { "type" : "Int" },
             "user"       : { "type" : "Int", "link":"customers.id" },
             "prev"       : { "type" : "Int", "nullable": true, "link":"this.id" },
             "message"    : { "type" : "Text", "analyzer": "English" },
             "operation"  : { "type" : "String" },
    
             "product"    : { "type" : "String", "nullable": true, "link":"products.name" },
             "tags"       : { "type" : "Text", "nullable":true, "analyzer": "English" },
             "response"   : { "type" : "String", "nullable":true, "analyzer": "English" }
           }
         },
    
         "impressions": {
           "type":"table",
           "columns": {
             "messageContext" : { "type": "Int", "nullable":true, "link": "messages.id" },
             "prevProduct" :    { "type": "Int", "nullable":true, "link": "products.id" },
             "customer" :       { "type": "Int", "link": "customers.id" },
             "product" :        { "type": "Int", "link": "products.id" },
             "query" :          { "type": "Text", "analyzer": "English" },
             "queryPhrase" :    { "type": "String" },
             "click" :          { "type": "Boolean" }
           }
         }
    
       }
     }
    
  2. Explanation:

Populate a new schema

To populate a new schema into aito, send a PUT request to

<_your_env_url_>/api/v1/schema/

with the provided read-write api_key and the schema in json format as content of the request

The training environment has already been populate with the schema

Delete an existing schema

Note: This will delete the entire database as well To delete an existing schema in aito, send a DELETE request to

<_your_env_url_>/api/v1/schema/

with the provided read-write api_key and empty content

Delete an existing table

To delete an existing table from aito's schema and from aito's database, send a DELETE request to

<_your_env_url_>/api/v1/schema/<_table_name_>

with the provided read-write api_key and empty content

Repopulate a deleted table

After deleting the table, you can repopulate a new schema with the deleted table and repopulate the deleted table to recover it

NOTE: Current version of aito does not support editing schema (E.g: update new link, update column type). Also, populating a new schema without table(s) does not delete the table(s) from the database The best practice is to delete the whole database (by delete schema), repopulate the updated schema, and repopulate the data content This will be improved soon in the future