Google Groups

Re: Something like Fuuton for touchdb?


Jens Alfke May 13, 2012 9:27 AM
Posted in group: Couchbase Mobile

On May 13, 2012, at 9:01 AM, Akash wrote:

Slightly off topic, but i couldn't find any discussion on why a conventional database has been used to "simulate" nosql, in the case of touchdb atleast.

It's in the FAQ:

Q: Why SQLite instead of a B-tree engine like Berkeley DB or Kyoto Cabinet?

A: Largely because SQLite is already available as a shared library on every platform we’re interested in; this keeps our code size down and simplifies the build process.

Additionally, both Berkeley and Kyoto have GPL-like licenses that are less friendly to commercial developers (especially iOS developers) and incompatible with the Apache license of TouchDB itself.


And in the "Why TouchDB?" document:

Storage Engine:

CouchDB contains a very clever B-tree engine with a lot of valuable characteristics. But rewriting it in a new language would be a big undertaking. There are a lot of other storage engines out there (Berkeley DB, Kyoto Cabinet, LevelDB…) but we’d have to consider their code size and licenses.

In the end, I think SQLite is the best choice. It isn’t a perfect fit for TouchDB’s data model, but you can’t beat its code size (effectively zero since it’s already incorporated into every OS). It obviously doesn’t scale up especially well, but that’s not an issue for mobile apps. SQLite is already very widely used as the persistence layer for a lot of apps, especially considering that Apple’s CoreData framework uses it.

SQLite is of course B-tree based, but its low-level B-tree API is considered internal and not recommended for developer use. Instead we can just use the regular SQL API to define tables and indexes for what we need. This has the advantage of moving a fair bit of the database logic intoSQL, making it cross-platform and reducing the size of the source code.