Databases Reference
In-Depth Information
As in the previous chapters, the topic of database modifi cation and evolution is explored in the
context of the three popular types of NoSQL products, namely:
Document databases
Column databases
Key/value stores
CHANGING DOCUME NT DATABASES
Document databases are schema-less in form, allowing self-contained documents to be stored as a
record or item in a collection. Being less rigid about a formal schema or form, document databases
by defi nition accommodate variations and modifi cations to the average form. In fact, a document
database doesn't prevent you from storing a completely disparate set of documents in a single
collection, although such a collection may not be logically very useful.
CouchDB, now part of Couchbase, and MongoDB, the two leading open-source document
databases, are extremely fl exible about storing documents with different sets of properties in the
same collection. For example, you could easily store the following two documents together:
{ name => “John Doe”, organization => “Great Co”, email => “john.doe@example.com” }
{ name => “Wei Chin”, company => “Work Well”, phone => “123-456-7890” }
Start up CouchDB and actually store these two documents in a database named contacts .
A MongoDB server can host multiple databases, where each database can have
multiple collections. In contrast, a CouchDB server can host multiple databases
but has no notion of a collection.
You can use the command-line utility, Futon, or an external program to interface with CouchDB
and store the documents.
CouchDB offers a REST API to carry out all the tasks, including creating and
managing databases and documents and even triggering replication. Please
install CouchDB before you proceed any further. There is no better way to learn
than to try out the examples and test the concepts yourself. Read Appendix A if
you need help setting it up. Appendix A has installation and setup instructions
for all NoSQL products covered in this topic.
Look at the screenshot in Figure 7-1 to see a list of the two documents in the contacts database, as
viewed in Futon. The list shows only the id, CouchDB-generated UUIDs, and the version number of
the documents.
Search WWH ::




Custom Search