While SQL databases are incredibly useful tools, their monopoly is coming to an end. NoSQL databases have been getting lot of attention over the last few years for their performance, scalability, schema flexibility and analytics capabilities. While relational databases are still a good choice for certain cases - like structured data and applications that require ACID transactions - NoSQL databases are better suited for use cases where:
- - The data stored is semi-structured or unstructured in nature.
- - The applications that access this data require a certain level of performance and scalability.
- - The applications that access this data are ok with eventual consistency.
MongoDB vs CouchDB
MongoDB and CouchDB have their strengths and weaknesses, but they also share some functionalities and features, so that they overlap in some situations.
Ideally, these two NoSQL database systems could be clearly positioned so that any user need would fall neatly into one of the two domains. But hey, we live in a real life and it's not always that way. This means that it is a bigger responsibility on software architects to choose the appropriate one for a project right at the beginning.
So, when should you choose each?
MongoDB
Written in: | C++ |
Main point: | Retains some friendly properties of SQL. (Query, index). |
License: | AGPL |
Protocol: | Custom, binary (BSON) |
In absolute terms, MongoDB supports high write loads with possible sacrifices of transaction safety. It also provides instant and automatic recovery from node or even data center failure. The document store is architected to scale easily and It is well suited to location-based data needs with spatial functions for accurately and rapidly finding data from specific locations.
One more thing: while not being full SQL, it has Query and Index functions that let users do many of the things that SQL databases do. Yet it does not enforce the limitation of predefined schema.
Best practical use: when you need dynamic queries; if you prefer to define indexes, not map/reduce functions, and when you need good performance on a big DB.
CouchDB
Written in: | Erlang |
Main point: | DB consistency, ease of use. |
License: | Apache |
Protocol: | HTTP/REST |
Written in Erlang, CouchDB adapts well to different sizes of computing device. It also allows users to work offline and to sync up their version of the database again when the next network connection is made. CouchDB scores highly for applications in which data is accumulated without any sizable requirements for modification. It also allows users to query a large amount of data rapidly.
By no means a minor issue, CouchDB interfaces easily with other systems, such as Oracle databases. A further advantage of CouchDB is in its features for deployment on mobile computing devices. The data store runs on Android, as well as BSD, Linux, OS X, Solaris and Windows.
Best used: For accumulating, occasionally changing data, on which pre-defined queries are to be run. Places where versioning is important.
Summing up
Of course, these database systems have many more features than the ones shown here. I only wanted to list the key points in which I base my decisions on. Anyway, to conclude I want to mention some other important differences between both database system:
- - MongoDB supports data typing, but not triggers. For CouchDB it’s the exact opposite.
- - CouchDB offers eventual consistency and master-master replication, while MongoDB gives users the additional choice of immediate consistency with master-slave replication instead of master-master.
About the platforms and programming languages supported, both database systems support a variety of ‘major players’. - Some other NoSQL database systems (like RavenDB, for example) only work on MS Windows because it is based on .NET (and supports only the .NET programming language).
As ever, analyze and test where possible before making any definitive deployment choices. I hope you’ve found this blog post informative.
About Facundo Lavallen
Facundo is a Software Engineer with more than 10 years of experience developing Web applications for some of the most important Fortune 500 companies
Nowadays Facundo works at the Engineering department of TISA, looking for implementing the latest technologies and frameworks to be used in future projects.
Beyond his technical knowledge and passion for the technology Facundo enjoys playing Ping-Pong, Soccer and Paddle.