irisk
irisk

Reputation: 111

MongoDB collections design

I've got such four tables: enter image description here

Point is that users that joined in particular group have access to a survey for time interval from date to date. How should i organize collection structure of such db in mongodb?

For survey and questions this will be a simple colection of surveys with an array of questions. But for this behavior with start/end of survey it is not clear for me how to store this data.

Upvotes: 1

Views: 125

Answers (1)

Rahul Kumar
Rahul Kumar

Reputation: 2831

What about something like.

Groups

{
 _id : "group1",
 "members" : [{"name":"A"...},{"name":"B"...}],
 "surveys" : [{"surveyId":"survey1", "startDate": ISODate(),"endDate":ISODate()},{"surveyId":"survey2", "startDate": ISODate(),"endDate":ISODate()}]
}

Surveys

{
 _id : "survey1",
 questions : [{"text":"Atheist??"...},{....}]
}

Honestly, it depends on what pattern you want to use, I mean you can embed groups inside survey also with registration details.

Upvotes: 4

Related Questions