Let's say I have 10,000 courses with course names. And 100,000 users who sign up for various courses. My user data model would contain something like...
course: [
{courseName: 'Programming 101',
cost: 0
},
{courseName: 'How to use stackoverflow',
cost: 100
}
]
But if I wanted to change a course name, then that would require me to update the thousands of user records who already have that course assigned as well. What is the best way of accomplishing this? Two queries with two tables? Is this a weakness of a nosql environment, or what is the efficient way of doing so?
Basically you have two options:
It really depends what you're trying to optimize your system for as to which one you choose. If you only end up changing a dozen or so course names each semester, option 2 probably won't be a problem.
Also, to answer your question about this being a weakness of nosql systems, yes, this is absolutely a weakness. This is not at all the type of problem nosql systems like Mongo are trying to solve. Mongo is great for certain problems but very bad for others. I would say that keeping a database of courses and students is not one of Mongo's strong suits. That is a prototypical relational data model and as such is more cumbersome to manage in Mongo than it would be in a classical RDBMS.