Many to many relationship on Mongodb based e-learning webapp? -
i relatively new no-sql databases. designing data structure e-learning web app. there x quantity of courses , y quantity of users.
every user able take number of courses.
every course compound of many sections (each section may video or quiz).
i need keep track of every section user takes, think whole course should part of user set (for each user), so:
{ _id: "ed", name: "eduardo ibarra", courses: [ { name: "node js", progress: "100%", section: [ {name: "introdiction", passed:"100%", field3:"x", field4:""}, {name: "quiz 1", passed:"75%", questions:[...], field3:"x", field4:""}, ] }, { name: "mongodb", progress: "65%", ... } ] }
is best way it?
i design database depending upon queries. 1 thing sure.. have embedding.
if going perform more queries on user doing, make user primary entity , embed courses within it. don't need embed entire course info. info course static. ex: data node js course - i.e. content, author of course, exercise files etc - not change. can keep courses' info separately in collection. how of course user has completed dependent on individual user. should keep id of course (which stored in separate 'course' collection) , each user can store information related (user, course) pair embedded in user collection itself.
now important question - if have perform queries require 'join' of user , course collections? can use javascript first courses (and maybe store them in array or list etc) , fetch user each of courses courses collection or vice-versa. there few drivers available online accomplish this. 1 unityjdbc available here.
from experience, understand knowing going query mongodb helpful in designing database because nosql nature of mongodb implies have no correct way designing. every way incorrect if not allow in accomplishing task. clearly, knowing beforehand (i.e. query) database guide.
Comments
Post a Comment