Hello everyone.
I am creating an application for events.
I have several data models
- Event
- Guest
- Organizers
There is a many to many relation between an event and a guest.
Each guest can register to many events and each event can have many guests (I’m talking about the hundreds, tops a thousand)
The thing is that I want to be able to query what events a specific guest is going to and what guests are in a specific event, both requires the name ( a list of names of events a guest is going and vice versa).
I’ve chose to have 2 collections (guests and events) and have each document have the respective id’s but because a common query is to get the names I’ve decided to refactor the model to be normalized meaning each guest have a list of basic events (objects that have name and id).
{
"_id": {
"$oid": "66b865d7efca7ad579233e4d"
},
"name": "Christiansen - Kihn",
"dressCode": "Only white",
"location": "Genovevachester",
"guests": [
{
"_id": {
"$oid": "66b9f775186812e09f2b3412"
},
"name": "Liel Shalom"
},
{
"_id": {
"$oid": "66b9f775186812e09f2b3411"
},
"name": "Liel Almo"
}
],
"date": {
"$date": "2024-08-11T07:18:47.801Z"
},
"isVipEvent": true
}
And vice versa to the guests collection
{
"_id": {
"$oid": "66b9f775186812e09f2b3412"
},
"name": "Skiles, Stark and Frami",
"events": [
{
"_id": {
"$oid": "66b865d7efca7ad579233e4d"
},
"name": "Christiansen - Kihn"
}
],
"isVip": true,
"age": 300
}
Now, I’ve search for several solution in the wild and seen the `subset’ pattern but I do not think this is the right pattern for me.
I’d love any help