nosql - How to structure a database design for a simple photo album in couchdb? -


i want try couchdb developping little photoalbum application different users can have many albums many photos in them. doing right if create document each users, contains array of albums, contains photos attachments?

{      user: "dominik",      albums: [          { name: "usa trip", photos:              [                  { title: "golden gate bridge", _attachments: [ photo ] },                 { photo }              ]         },         { ...} ]  } 

or there way this?

or better store users, albums , photos each in different documents? require foreign keys in mysql?

{ type: "user", name: "dominik", albums: [ "a1", "a2", "a3" ] } { type: "album", _id: "a1", title: "usa trip", photos: [ "p1", "p2" ... ] } { type: "photo", _id: "p1", _attachments: {...}, title: "golden gate bridge" } 

...

or other way around?:

{ type: "user", _id: "u1", name: "dominik" } { type: "album", _id: "a1", title: "usa trip", user: "u1" } { type: "photo", _id: "p1", _attachments: {...}, title: "golden gate bridge", album: "a1" } 

1999 right. 2 more minor points:

  1. remember, apache couchdb supports atomic transactions—but within document. can change in document single atomic operation.
  2. in couchdb security framework, security policy applied 1 document @ at time, in isolation. validate_doc_update function cannot see foreign documents when has decide user may do. (if not use couchdb accounts , authentication, not relevant.)

Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -