1

I need to implement an event calendar in firebase.

The requirements are:

  • a user(agent) can work for one or more agencies(agent needs to see which artist is free or booked for a specific date)
  • a user(manager) can work for one or more agency/venues
  • a public user can see list all events for a particular artist / venue

Can somebody please help me find a good firebase structure for storing this data?

calendar:
 - calendarId
 - timestamp
 - description

user-calendars:
 - calendar1Id:true
 - calendar2Id:true

I think this would be a good structure for a private calendar, but how to get all the events for a particular artist or a particular venue?

venue-events:
-id
-timestamp
-name

agency-events:
-id
-timestamp
-name

users:
-id
-name

agency:
-id
-name

venue:
-id
-name

artist:
-id
-name

Update1:

If I create an event table:

events:
-eventId1
   -name: "Firebase is awesome"
   -date: 09092017
   -artists: 
     -artist1Id:true
     -artost2Id:true
   -venues:
     -venue1Id:true

Now I have a common event table but for fetching events for a particular artist I would need:

-artist-events:
  -artist1Id:
     -event1Id:{copy all data of the event}

Morover I would need this also for agency,venue..This is the only effective way to retrive later on my data.

My concern is it will not be too complicated for updating all the nodes?

I use functions but still.

thank you

Community
  • 1
  • 1
Miha
  • 31
  • 1
  • 4
  • Those all sound like valid structures, adding nodes/duplicating data as needed for your use-cases. What is your concern? – Frank van Puffelen Aug 23 '17 at 07:36
  • Please check update1 in the question. Thank you – Miha Aug 24 '17 at 15:03
  • I still don't fully understand what you're asking. If you wonder whether data duplication is normal, then: yes it is. But the optimal level of duplication is dependent on the app and your other needs, so hard to say up front. If you want to know strategies for keeping the denormalized/duplicated data in sync, see my answer here: https://stackoverflow.com/questions/30693785/how-to-write-denormalized-data-in-firebase – Frank van Puffelen Aug 24 '17 at 16:12

1 Answers1

1
user-calenders:
   canlenderId:
       venue/agency-event:id:name  // fetch more details using id
user:
  ...
  ...
  agencies:[agency1,agency2,...]

for artist will you be using the same calender ?

Umar Hussain
  • 3,461
  • 1
  • 16
  • 38
  • 1
    This is a good starting point. But please don't use an array to model a set. So `agencies:[agency1,agency2,...]` -> agencies:{agency1:true,agency2:true,...}`. See my answer here for more http://stackoverflow.com/questions/40656589/firebase-query-if-child-of-child-contains-a-value – Frank van Puffelen Aug 23 '17 at 07:34
  • very good explanation (Y), I was also getting confused on this choice for my use case as well. – Umar Hussain Aug 23 '17 at 07:39