4
I’m studying firebase that uses Nosql and I came up with a question when watching this video: Converting SQL Structures into Firebase Structures - Firebase Database for SQL Developers #2
In it the author creates a structure like this:
Blz...with this structure it would be very easy to return all the participants of a given event just going through the eventAttendees node.
But what if I want to know all events that a certain user participates in. How would I do? If I create another usersAttendees node I could do this by saving users and within each user the events it participates in.
But then we have a problem: data duplication. If there is a modification, say, if I remove an event from the David user, I will have to remove it from both nodes : eventAttendees and usersAttendees.
This would be easily done using SQL modeling as in the photo but the goal here is to do using Nosql:
So my question is, what’s the best way to model this in Nosql to avoid this kind of problem?
EDIT: I realized that this problem persists for any relationship n to n. So specifying further, my doubt would be how to make n to n relations with Nosql in the best possible way?