In a relational database you would usually have an events table and have a one-to-many relationship between students and events. However, our limiting factor with Firebase is reads,writes deletes - needing to do a join on events, which in essence is doing a read on each event a student attended becomes VERY expensive really quick.
Instead what might be best is to have an events collection (table in a relational database) that includes just the necessary info about the event and doesn't have any fields that keep track of attendees.
Possible schema:
{ ...currentUserInfo, events: [ { eventName: 'event' <- String, eventType: (GBM, Study Night, etc. - could be nice for analytical/stat purposes) date: YYYY-MM-DD (or whatever format is common in firebase) <- date, eventId: Firebase document ID } ] }
Schema for an events document:
Utilize the increment function in Firebase for incrementing the attendes. Tutorial here { eventName: 'an amazing event', location: Where the event is located <- string, roomLocatorUrl: 'utd room locator url ' <- string, eventPicture: 'url for some kind of picture stored on our cdn for events' <- string, attendees: number of attendees <- Integer }
In a relational database you would usually have an events table and have a one-to-many relationship between students and events. However, our limiting factor with Firebase is reads,writes deletes - needing to do a join on events, which in essence is doing a read on each event a student attended becomes VERY expensive really quick.
Instead what might be best is to have an events collection (table in a relational database) that includes just the necessary info about the event and doesn't have any fields that keep track of attendees.
Possible schema:
{ ...currentUserInfo, events: [ { eventName: 'event' <- String, eventType: (GBM, Study Night, etc. - could be nice for analytical/stat purposes) date: YYYY-MM-DD (or whatever format is common in firebase) <- date, eventId: Firebase document ID } ] }
Schema for an events document:
{ eventName: 'an amazing event', location: Where the event is located <- string, roomLocatorUrl: 'utd room locator url ' <- string, eventPicture: 'url for some kind of picture stored on our cdn for events' <- string, attendees: number of attendees <- Integer }