I think role should be a separate entity. A user can have multiple roles, thus it'd b best not have role information (except the ids of the roles) in the user entity
I still think you should think ahead here and have a role entity, the user points to. A user "can" have multiple roles means they can still have 1 and be totally fine. It'd probably be harder to change the schema afterwards.
The balance is how costly joins with this new entity are, but I'm not familiar with MongoDB much to be of help for this. It probably depends also on the size of your DB
Hi Anshul!
I think
role
should be a separate entity. Auser
can have multiple roles, thus it'd b best not have role information (except the ids of the roles) in theuser
entityI have edited question with an example.
Having multiple roles is another scenario.
I still think you should think ahead here and have a
role
entity, theuser
points to. A user "can" have multiple roles means they can still have 1 and be totally fine. It'd probably be harder to change the schema afterwards.The balance is how costly joins with this new entity are, but I'm not familiar with MongoDB much to be of help for this. It probably depends also on the size of your DB
I am new to database design so considering present requirements I have designed a model. I have commented in the above post.