Skip to content
Laurent MICHEL edited this page Nov 15, 2020 · 4 revisions

JSON Map of a Table Hierarchy

JSON Model

The json map has 3 blocks:

  • root_table: gives the location of the root table
  • table: flat list of all the tables contained in the hierarchy. This flat list allows a direct acces to table descriptions without browsing the hierarchy.
    • The ADQL constraints are put here
    • The attribute handlers are stored here on demand (getAttributeHandler method)
    • This block is used as a cache for the attribute handlers
  • map: table hierarchy with join rules.
{
  "root_table" :{
      "name": "root_table_name",
      "schema": "schema"
  },
  "tables":{
     "table1" :{
       "description": "...",       
       "columns": [],
       "constraints": ""
     },
     "table2" :{
       "description": "...",       
       "columns": [],
       "constraints": ""
     },
     "table11" :{
       "description": "...",       
       "columns": [],
       "constraints": ""
     },
     ...
   },
  "map": {
    "root_table_name":{
       "join_tables": {
          "table1": {
            "from": "oid",
            "target": "oidref",
            "join_tables": {
               "table11": {
                 "from": "key1",
                 "target": "key11",
                 "join_tables": {}
                 }
            },
            "table2": {
              "from": "key1",
              "target": "key2",
              "join_tables": {}
             }, 
           ...
  }
}

Usage Rules

  • When attribute handlers are requested, the API will first look at the tableblock whether the attribute handlers are already in the column field. If not, they are searched in the DB and stored in the json.

  • Constraints are set (and removed from) the tables elements.

  • To build a complex query, we go through the map. On each node we look at tables to see whether there is a constraint. If there is one, we build the join accordingly.

Clone this wiki locally