0

I currently am storing raw JSON in a table as I cannot figure out how to create a table structure for the data I am using. The JSON example I have is:

{
  "type": "HEADER",
  "value": "Welcome"
},
{
  "type": "LIST",
  "children": [
    {
      "type": "ITEM",
      "value": "My item!",
      "description": "Item description"
    }
  ]
},

The issue I have is that the objects can be nested, for example inside the object LIST, you can have more LIST, ITEM, or HEADER. I would appreciate some suggestions on how this would translate to a relational database.

  • 1
    For the example given, you'd have three tables that use FK's to reference each other. However, JSON has the advantage that it can take whatever form it likes, so you'd need to understand if there is any limitation / JSON schema attached to this that helps define for example, how deep can the nesting go, are there any parent/child relationship not allowed. That will help you model the target schema. It's possible there is no perfect schema for this. Depending on your use case you could just store the JSON documents in a document db like CouchDB, CosmosDB, DocumentDB, MongoDB – Nick.Mc Sep 28 '21 at 03:06
  • Does this answer your question? [What are the options for storing hierarchical data in a relational database?](https://stackoverflow.com/questions/4048151/what-are-the-options-for-storing-hierarchical-data-in-a-relational-database) – solarshado Oct 06 '21 at 04:55

0 Answers0