this follow-up question on mongodb : limit between "few" , "many"?.
i come relational database world , working on new nosql project mongodb.
edit: working on project rails, , decided move meteor prototyping, requires use mongodb. providing below information explain had come in terms of database schema when working on rails version of project.
this project based on following collections:
user firstname lastname emailaddress password calendar title role userid calendarid post calendarid date time focus format blogtitle longcopy shortcopy link hashtag media promotion target approval comment a user able create , manage several calendars , calendar allow several users collaborate.
i believe few-to-few (not many-to-many) association since:
- a
usershould not have more couple dozenscalendars - a
calendarshould not have more dozenusers
the access pattern following:
- a user log in, , automatically presented list of calendars.
- the main action of
userchoosecalendar, edit content (crudpostswithin given calendar). - sometimes, not within every session,
userneed access , crud list ofusersbelonging 1 ofcalendars.
what best way structure such project mongodb?
one of design pattern storing calendar associated each other in own document. duplicate calendar data user interaction fast because log in can see calendar can fetch in 1 request.
{userid : 'x1' , cal = [{} , {}]} only catch here when update calendar have find document having calendar , update it. read fast in pattern write little slow.
using proper index make faster find document having specific call
db.collection.update({cal.id : 123},{});
Comments
Post a Comment