Hi Andreas, I am glad that you want to switch from mysql to couchdb as many of us did. As I figured out that always the same incompatible mindset of relatioinal thinking prevents users to investigate the necessary time to learn how to work with relations without sql, find my 50 cents regarding your questions as best practices in my last 9 years of couchdb usage:
- should view only contain _ids or also all the data you want to fetch? --> views should fetch all relevant data you need for a specific app or part of an app, exactly as you need it in the frontend so that your frontend code does not need further transformation complexity. - what do you do about nested Documents, get them in the view or fetch the while rendering using lists / shows / templates (design doc)? For example calling db.openDoc() in list to get data of doc or nested doc. --> you should not nest documents. as smaller your data gets saved as better your replications performs, as less diskspace you need and as better your application can be maintained, debugged and extended. - when i check for overlapping should i use views and then write a js-function to step through all results and check stuff or is it better to use nQ1-queries (pseudo-sql)? For example: --> try to use a view where all operations are made in the js view code to have the best performance. I cannot give you any advice for nQ1-queries because I think that pseudo-sql may help to get foreward with an sql mindset faster on nosql databases but could also prevent to get the correct nosql mindset to work with structured js-quries and efficient map functions based on intelligent document ids on start-end ranges. I like following list of best practices (thanks to Jan for sharing) which could help you most: http://ehealthafrica.github.io/couchdb-best-practices/ Best, Harald On Sat, Dec 10, 2016 at 11:15 AM, Andreas Owen <[email protected]> wrote: > I have read a couple of articles about couchdb and nosql modelling > because I’m finally changing from mysql. Unfortunately I still haven’t been > able to answer a couple of questions, maybe someone can enlighten me. > > i have a design document with views,lists,templates that make up an app > and i’m using the builtin web-server. My app works with appointments in > calendars where i have to check overlapping and minimum separation time on > so on. that means i’m working a lot with date ranges, durations and > weekNumbers. Appointments can also have linked/nested documents so > sometimes i have to fetch other docTypes with a doc. > > questions: > - should view only contain _ids or also all the data you want to fetch? > > - what do you do about nested Documents, get them in the view or fetch the > while rendering using lists / shows / templates (design doc)? For example > calling db.openDoc() in list to get data of doc or nested doc. > > - when i check for overlapping should i use views and then write a > js-function to step through all results and check stuff or is it better to > use nQ1-queries (pseudo-sql)? For example: > appointment2.start >= appointment1.end + minSeperationTime && > appointment2.end <= appointment3.start + minSeperationTime > > > >
