Key - Value store vs. Relational database in Cloud context
- Scalability: K-V databases are more scalable as compared to relational databases. Scaling up and data replication is not a problem with K-V stores as they store data in the key-value format. In cloud based services and application where data explodes exponentially with popularity, this is one of the key requirement. For e.g., due to increasing popularity of applications like Facebook (uses cassandra), linkedin (voldemort), twitter (uses cassandra), etc are using K-V stores for their data management.
- Data Availability & durability: Data is replicated on different nodes in case of K-V stores. All of the nodes are updated with latest data and nodes containing latest data are identified while retrieval. This marks K-V stores for high availability & data durability.
- Data Integrity: Data integrity is lost in K-V databases as there is no scope of defining the datatype. A String value can be entered successfully for the key where integer was expected because value holder is common for all keys and the user can end up throwing a number format exception due to this. On the other hand, this is not allowed in relational databases as this check is present at DB level itself. Though this can be considered as advantage also as user don't have to deal with datatypes in K-V stores.
- Data Creation: K-V stores do not follow object-relational mapping. This binds the data layer with the application logic to some extent unlike relation databases. Hence to modify/create data, custom API has to be written rather than standard API calls/ simple SQL queries as in case of relational database.
- Fetching data : K-V store makes data fetching a little complex.
For e.g. :
Select CUST_ID from CUSTOMER where LOCATION="INDIA";In case of relational DB, one can easily fetch data using a simple select sql query like:
Select CUST_ID from CUSTOMER where KEY1='LOCATION' and VALUE1='INDIA';In case of K-V, the same has to be implemented as
With increase in conditions, query complexity will also increase.
Extensibility : Relational databases are strongly schema typed i.e. any change in table structure needs DBA interference. Whereas in case of K-V store, one can easily add the column without changing the table structure and without the help of DBA. Hence, it provides more flexibility.
Due to the advantages like high availability, simplicity, high scalability, low latency and replication mechanism of K-V stores, they are generally preferred over relational database for cloud based applications. There are many market leaders like Amazon's simple db, project voldemort, Cassandra, couch db which takes care of all technical complicacies and have an a simple API for meeting users' requirements packed with all advantages of cloud databases.