I am developing an application where I have multiple types of users Admin, Trainer, Trainee who have few fields in common and few fields specific to the user.
Ex:
Trainer{
Name: string,
Email: string,
Mobile: string,
ExpertIn: string[],
Rating: number,
...
}
Trainee{
Name: string,
Email: string,
Mobile: string,
Coureses:string[],
AverageScore: number
...
}
Is it good to store all types of users in single collection or keep common fields in users collection and specific details in different collections like (Trainer, Trainee) in terms of MongoDB 4.0 (keeping transactions and joins in mind)?
Usermodel with type attribute. For courses, you can haveCoursesmodel which will haveuserIdorownerId, which will beuserIdwhich is trainer. Similarly for other models. You can also havetypemodel. Which will be property onusermodel.