Cosmos DB offer multiple models as below:
- Document Model with SQL API
- MongoDB Model with MongoDB API
- Cassandra Model with Cassandra API
- Table Model with Table API
- Graph Model with Gremlin API
In this article we can see which model to choose based on the requirement.
Note As informed previously we are making a Choice of CosmosDB here due to Dynamic Schema requirement & Geo-replication.
Document Model with SQL API
If you are starting with a new project which requires storage of similar items, schema changes a lot, then SQL API is the best choice.
MongoDB with MongoDB API
If you are Migrating from existing MongoDB which have Investments of MongoDB Queries then MongoDB API is the best choice.
Cassandra Model with Cassandra API
If your project requires Web Analytics capabilities, then Cassandra API is the right choice.
Table Model with Table API
If your data consists of Key-Value pairs OR if you wanted to Migrate data from Azure Table Storage, then Table Model API would be right choice.
- Cosmos DB (access based pricing) is Cheaper than Table Storage (size based pricing) depending on the case
Graph Model with Gremlin API
If you have relationships between data, then Graph Model is the best choice.
Example: Amazon wanted to show Product Recommendations like customer who bought LG TV 46” also bought another product TV Stand 46”
graph.V().hasLabel(‘product’).has(‘productName’, ‘LG TV’).addE(‘boughtWith’).to(g.V().hasLabel(‘product’).has(‘productName’, ‘TV Stand’))