Dhibin Dinesh
Dhibin Dinesh

Reputation: 71

Firebase database for survey results

I am trying to store my survey results data in the firebase database. I have structured it as the following: organization_id > survey_id > user_id > question_id : choice_id

Example : 2:organization_id, 25: survey_id, 225: user_id, 101: question_id, 1/2/3/4/5: choice_id

firebase database structure

I want to show how many users selected a particular choice for a question. Expected result

  1. How can i do that using firebase java-script API's ?
  2. Is there any better ways to structure this data ?

Upvotes: 1

Views: 804

Answers (1)

Stradosphere
Stradosphere

Reputation: 1285

You are probably going to want another node that keeps the number of choices selected per question. Something like:

org_id > survey_id > question_id > totals > choice1: numberResponses
                                          > choice2: numberResponses

Its common to have to store the same data in a different format depending on how your application will use it.

Upvotes: 1

Related Questions