I have many years of experience with RDBMS. I am relatively new to NoSQL. And in the current project I am doing, I have to use MongoDB (as suggested by my client).
In this there are tens of thousands of students and hundreds of exams. I will receive information about students and exams in JSON format. So I plan to have these two collections in MongoDB:
Each document in this collection will have information about each exam. Together with all other fields related to exams, the document will have a field
ExaminationName That could be referred to in other collections.
In this collection we will store information for all students. There will be one document per student. Together with all other fields in the document, you will have
ExaminationName (Blank if there is no associated exam) as a mandatory field in this collection. Therefore, each student is associated with one or no exam.
The questions are:
Is this design approach correct? If the name of the exam is given, can I get a collection of those students associated with the exam? (that is, search for documents by one of the values in the Student collection)
One suggestion I received is that I do not need to worry about duplication of data in NoSQL and in the collection of Exams, I must store the information of the associated students (and it will also be there in the Students). In this way, it is quick to obtain information from students associated with a particular exam. However, I thought that if I needed to change the information of a particular student (for example, the student's name), I will have to make those changes in two places. Is there any solution that MongoDB provides to avoid this? (when they say Duplicate the data (but limited) because disk space is cheap compared to the calculation time)