jorge.munin
jorge.munin

Reputation: 37

Define firebase json structure nested list

I want to create a database structure for my realtime database in firebase. Right now I have list and those list have sublist. Those sublist have products and users.

To get the users in a sublist I defined his own object

"SubListUser" : {
 "SubListId1" : {
  "User1Id" : {
    "username" :"String",
    "photoUrl" : "String"
  },
  "User2Id" : {
    "username" :"String",
    "photoUrl" : "String"
  }
  "ListId": "ListId1"
}

And to get the products I have this JSON object

"SubListProducts" : {
  "SubListId1" : {
     "Products" : {
       "ProductId1" : {
         "name" : "String",
         "productPhotoUrl" : "String"
       }
     "ListId": "ListId1"
}

Those subLists are inside other lists. To know the sublist in a list I have this object

{ "Lists": 
    "List1": {
      "subList1" : "SubListId1",
      "subList2" : "SubListId2",
    }

}

If I want to know the products/users of a sublist is this okay? Because if I want to know the products/users I have to do 2 finds first find the list with their sublist, and then find the products/users of that sublist.

I don't know if this is good or should I redo my database?

Upvotes: 0

Views: 102

Answers (0)

Related Questions