Foreword: assumptions forthcoming :)
The relationship you are describing is perfect for the JSON document structure. Forget the has_many
and belongs_to
for this scenario. Use JSON's ability to nest objects in a arrays. I would recommend you to quit using a ODM in the short-run while you get your head around MongoDB's expressive documents.
Add the modules
as needed to a nested array on a syllabus. Then, allow the teacher to modify the content for that syllabus only. You would have something like the following for the syllabus:
{
course_id: ObjectId(),
modules: [
{
module_template_id: ObjectId(),
name: "bla bla bla",
description: "bla bla bla",
due_date: "2013-09-28",
modified_from_template: false
},
{
module_template_id: ObjectId(),
name: "bla bla",
description: "bla bla customized",
due_date: "2013-10-05",
modified_from_template: true
}
]
}
You would have another module_templates
collection that is the parent
manpreet
Best Answer
2 years ago
I am not very experienced in db design, and have not built something like this before, where it involved creating and managing lists, so any advice is much appreciated. Performance can be tuned later on, much more concerned about maintainablity and extendsability.
I am using mongodb, and I allow teachers to create their personal educational syllabus that is made up of individual reusable modules. A teacher can in turn customize the syllabus for different students.
Option 1: Store numerical sequence in the "joint" table:
To edit it, I pretty much s://forum.tuteehub.com/tag/need">need to reset all the sequences everytime a modification to the program is made.
Option 2: Store records with a pointer to a before and after
Option 3: Store module ids as an array inside Syllabus
This is obviously the simplest, but I would not be able to store program/module specific information. also, i s://forum.tuteehub.com/tag/need">need to do my own validation checks
Another consideration is that I would s://forum.tuteehub.com/tag/need">need to allow teachers to in turn customize the syllabus for students too, something like this...
Any help will be much appreciated!