Chapter 15. Using Nonrelational Databases
After years of relational databases being the only functionally available choice for application developers needing to persist data, a number of new classes of databases have come to be regarded as legitimate alternatives to the ubiquitous RDBMS. These databases are each generally very different from each other. Despite their differences, key-value stores and column- and document-oriented databases share a common thread of presenting alternatives to the orthodoxy of the relational data model that has dominated for so long; thus, they are often collectively referred to as nonrelational databases. These data stores’ unique capabilities and increasing popularity make them common components in new Clojure applications, so it’s worth seeing what such a combination looks like.
CouchDB is a document-oriented nonrelational database that defines a data model and architecture that fits well with Clojure’s strengths and world view. The combination is particularly potent, allowing for the relatively simple implementation of many types of applications, from typical web frontends to pleasantly extensible messaging systems.
To start, it would be helpful to describe a couple of CouchDB features that are particularly relevant to Clojure:
Its data model consists exclusively of JSON documents, which are trivially converted to and from Clojure’s data structures.
It uses an append-only btree-based storage system that defaults to ensuring data durability and ...