I\'m novice with firebase and I try to structure my data to store friendship between users of my app.
My data are structured like this :
{ users:
You shouldn't store name in the friendships structure, only the usernames. So friendships should look more like this:
{
friendships: {
user_1: [
user_2,
user_3
],
user_2: [
user_1
]
}
}
This way if you update name, you only have update it in one place (users). You can cross-reference the username from friendships with the username in users to find name.
Also in case you use push() for friendships, the structure will change a little, but the same principle applies:
{
friendships: {
user_1: {
-KPE008BeSzNR5D3W7t3: user_2,
-KPE0nF4AW7Lj66xTLUu: user_3
},
...
}
}