0

I have the following exemplary data structure:

"peopleOfFame": {
  "asd456789": {
    "firstName": "John",
    "lastName": "Wayne",
    "dateOfBirth": "19660702"
    "marriedTo": "yxc321lkj"
  },
  "yxc321lkj": {
    "firstName": "Jennifer",
    "lastName": "Aniston",
    "dateOfBirth": "19620228"
    "marriedTo": "asd456789"
  }
},
"relationshipsAmongstPeopleOfFame": {
  "asd456789yxc321lkj": {
    "asd456789": true,
    "yxc321lkj": true,
    "datingSince": "20170729",
    "children": "0",
    "happy": true
  },
  "yxc321lkj": {
    "asd456789asd456789": true,
    "yxc321lkj": true,
    "datingSince": "20170729",
    "children": "0",
    "happy": true
  }
}

Is there any downside to using the combined ids of the peopleOfFame as the id for the objects in relationshipsAmongstPeopleOfFame?

I feel like this is a good use case where our life would be easier and queries would be faster doing it this way. I've read a ton about data structures in Firebase and I have not come across those examples yet. Neither in a way that encourage them nor discourage them.

Obviously, we have limited use when the number of potential ids grows. But I am talking about clear cut cases where two stored objects form another single stored object.

So, in summary, my question would be: Can you provide me with counter arguments as to why this approach is not good? Or can you encourage me and show me further use cases for this? I feel like there is not a lot out there with those specific 2 objects => 1 object examples.

Spurious
  • 1,903
  • 5
  • 27
  • 53
  • 2
    It's pretty much what I recommended here (I just used names as a more readable example): http://stackoverflow.com/questions/33540479/best-way-to-manage-chat-channels-in-firebase. The only think I'd keep in mind is to ensure the IDs are in a predictable order. – Frank van Puffelen Jul 28 '17 at 23:07
  • @FrankvanPuffelen: Thanks for the link, the idea with SHA hashing is brilliant as well. Is there anything that speaks against this? In case I have multiple people in an object, e.g. a family. – Spurious Jul 29 '17 at 07:32

0 Answers0