I have a collection in Mongodb( Users
) and a collection ( GroupTask
)
Task
) objects.
How can I have Users referencing a Specific Task object inside a Specific GroupTask Object?
EDIT::
My user table is:Username
Password
OpenIDurl
MemberSince
Role/Permissions
GroupTask is
Name
DateStarted
CompletionDate
NumberOfTasks
NumberOfSubscribedUsers
<<Tasks>> // Embedded array
A task is:
Name
Description
DateStarted
DateCompleted
Progress
Each user needs to reference many tasks and each task can开发者_StackOverflow中文版 have more than one user. The only problem is that task is embedded into task group.
It is difficult to answer without more information on your application and its access patterns and how you plan to use this data. A similar situation with products and categories is discussed in http://www.scribd.com/doc/47326395/MongoBoulder-Schema-Design
I think you need to embed some of the fields of your user objects into your GroupTask objet, like PK, username, email. And if you change any user object, fire an update in GroupTask collection.
精彩评论