Basic Principles of NoSQL Databases¶
NoSQL databases are well-known for their easy scalability and speed. However, their internal design has other drawbacks.
Differences between NoSQL and SQL¶
NoSQL are designed on the BASE principle:
- Basically Available: read and write operations are always available on all nodes, at the cost of consistency (reads do not necessarily return the most up-to-date data).
- Soft state: without the guarantee of consistency, after some time, we can only predict the state with certain probability.
- Eventually consistent: if the system is functional, the data will eventually get to consistent state, after enough time has passed
These are large drawbacks, when compared to ACID-compliant databases. NoSQL does not guarantee atomicity of transations and replication is asynchronous. You have to be aware of these restraints when designing your application. NoSQL databases are not suited for some types of data. A typical example is payment processing. That kind of data always needs to be saved to an ACID database.
Another difference between SQL and NoSQL is their behavior during network outages. NoSQL maintains service availability (all queries receive non-error response), while SQL favor data consistency (all reads receive newest data or error).
Among NoSQL database advantages are straightforward application design, easy scaling and ability to store large amounts of data. But when choosing which NoSQL database to use, you should carefully think about kind of data are going to save in it. NoSQL databases are most commonly key-value, but there are special databases for objects, documents, graphs, xml etc. as well. Some products are universal and support multiple storage engines. Therefore, choosing the right database for your project is key.