We are trying to create a simple chat application using Firebase as the backend. We are struggling with the right data structure to use.
So we have rooms and users. It's a many to many relation: one room can have many users as members and one user can be a member of many rooms. How do we structure this data?
If we do the following:
room {
name: ,
desc: ,
members: [
users {
name: ,
email: ,
age: ,
bio: ,
...
}
]
}
How do we update the user details when that changes? And if we did the opposite, of having rooms a property of the users node, how do we update the rooms? I considered having another object relations with a pointer to room and a pointer to member, but I didn't find a way to use pointers in Firebase.
relations {
user: <pointer to users>
room: <pointer to rooms>
}
Any advice would be helpful. I have looked at various articles including Anant's Denormalizing you Database is normal, but haven't been able to solve our case.