Eastern Monk
Eastern Monk

Reputation: 6635

CouchDB: "Database-per-user" or "One-Database-For-All" design?

I am building a simple bookmarking application where users will have extensions installed in their browsers which will sync the local bookmarks into our app.

I am using CouchDB to store the user data. If scalability is what I am aiming at, they what is the best way to use CouchDB given the following options?

  1. Have one couchDB and put everything into it.
  2. Create a dedicated database for the user and let bookmarks be stored as a document.

Anything else?

Upvotes: 9

Views: 1526

Answers (1)

pokstad
pokstad

Reputation: 3461

A dedicated database-per-user is more important when you don't want other users to be able to read the contents of another user's database. This is because CouchDB cannot enforce read-permissions on a per document basis, only per database. The problem with creating many databases is that you cannot create Views that span across databases, Views can only operate on documents in a single database.

General rule of thumb: if privacy concerns of a user's data is not that important, use one big database.

Note: This only applies to CouchDB by itself. You can get around this permissions limitation if you have another layer of software in front of CouchDB, like a proxy or a web framework doing authentication.

Upvotes: 15

Related Questions