Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 859
Eastern Monk Avatar asked Sep 16 '11 14:09

Eastern Monk


People also ask

Is CouchDB distributed?

CouchDB is a peer-based distributed database system.

What type of database is CouchDB?

Apache CouchDB (CouchDB (link resides outside IBM)) is an open source NoSQL document database that collects and stores data in JSON-based document formats.

Where is CouchDB data stored?

By default, the database files are located under /var/lib/couchdb directory (this location will be specified in the couchdb config file under /etc/couchdb directory). In CouchDB, each database is wholly contained in a single append-only file.

Is CouchDB document based database?

Apache CouchDB is an open-source document-oriented NoSQL database, implemented in Erlang. CouchDB uses multiple formats and protocols to store, transfer, and process its data. It uses JSON to store data, JavaScript as its query language using MapReduce, and HTTP for an API.


1 Answers

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.

like image 70
pokstad Avatar answered Oct 27 '22 08:10

pokstad