skip to Main Content

I have a hierarchical lineage for object dependency in json format. The json itself has a very simple structure but it has variable depth. I have attached an image to show the tree structure. The depth of the json could be variable as it an object lineage of dependencies which could be n level deep.

The structure of the lineage is that is starts from a Dashboard >> Cubes / Reports >> Report Objects >> Schema Objects >> Tables / columns, but the dashboard could have multiple cubes and reports. The cubes itself could comprise of multiple reports, so there could be circular dependency. However, all the lineage’s start (root) would be a dashboard and it would end with a table / column. Some could have 5 levels, some may have 20+.

I wanted to understand what is the best way to store this data and if there are any recommendations or best practices for storing it in a structured format. The end goal to have a standard data model to load such datasets and eventually represent them graphically as an org chart or tree diagram to show the lineage. So the json structure should be parse able for creating a deep tree / network chart.json-structure

{
  "id": "String",
  "name": "String",
  "type": Integer,
  "subtype": Integer,
  "location": "String",
  "dependents": {
    "id": "String",
    "name": "String",
    "type": Integer,
    "subtype": Integer,
    "location": "String",
    "dependents": {...}
  } 
}

2

Answers


  1. You can use a recursive structure as you have, where each node can contain dependents that follows the same structure as the parent. That is a common practice for representing trees in JSON.

    For storage and processing, you can use a NoSQL database like MongoDB, which handles JSON natively, or in a relational database with JSON support, such as PostgreSQL.

    Make sure each node has a unique identifier, and use standard keys for each level (e.g., id, name, type, subtype, location, dependents)
    Consider using a graph database for complex dependencies and querying, like Neo4j.
    To represent data graphically, use libraries like D3.js or vis.js, which can parse your JSON and create interactive charts.

    You can update your structure to include a reference system for managing circular dependencies. For instance:

    {
      "id": "dashboard1",
      "name": "Main Dashboard",
      "type": 1,
      "subtype": 1001,
      "location": "Location1",
      "dependents": [
        {
          "id_ref": "cube1"
        },
        {
          "id_ref": "report1"
        }
      ]
    },
    {
      "id": "cube1",
      "name": "Sales Cube",
      "type": 2,
      "subtype": 1024,
      "location": "Location2",
      "dependents": [
        {
          "id_ref": "report1"
        }
      ]
    },
    {
      "id": "report1",
      "name": "Annual Sales Report",
      "type": 3,
      "subtype": 1032,
      "location": "Location3",
      "dependents": [
        {
          "id_ref": "table1"
        }
      ]
    }
    

    For each dependent that is a reference to another entity, id_ref is used to link to the actual entity with that id.
    That helps avoid circular dependencies within the JSON structure itself and makes it easier to parse and visualize.

    Login or Signup to reply.
  2. I would follow the Hierarchical Approach similar to represent as a tree diagram and I would include unique identifiers for each level (e.g., dashboard ID, cube ID, report ID). This can help handle circular dependencies and maintain uniqueness.

    {
      "dashboard": "Dashboard_Name",
      "cubes": [
        {
          "cube": "Cube_Name",
          "reports": [
            {
              "report": "Report_Name",
              "report_objects": [
                {
                  "object_type": "Schema_Object",
                  "objects": [
                    {
                      "table": "Table_Name",
                      "columns": ["Column1", "Column2"]
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search