Microsoft Azure Data FundamentalsDescribe how to work with non-relational data on AzureHard

A startup is building a social media application where users can follow each other, and posts can have many comments and likes. They need a database that can efficiently store and query complex relationships between users, posts, comments, and likes. Which Azure Cosmos DB API is the most suitable for this use case?

  1. ACassandra API
  2. BSQL API (DocumentDB)
  3. CGremlin API
  4. DTable API
Show answer & explanation

Correct answer: C. Gremlin API

The Gremlin API for Azure Cosmos DB is specifically designed for graph databases. Graph databases are excellent for modeling and querying highly connected data, such as relationships in a social network (users following users, posts having comments, etc.), making it the ideal choice for this scenario.

Why the other options are wrong

  • A. The Cassandra API is a column-family database, suitable for large-scale, high-throughput writes, but not optimized for complex relationship queries.
  • B. The SQL API is a document database, good for semi-structured data, but less efficient for querying complex, multi-hop relationships inherent in social graphs.
  • D. The Table API is for key-value data, which is too simplistic for the complex relationships required in a social media application.

Azure Cosmos DB Gremlin API

An API for graph databases in Azure Cosmos DB, allowing efficient storage and traversal of highly connected data.

  • Uses Apache TinkerPop Gremlin query language.
  • Ideal for modeling relationships (social networks, recommendation engines).
  • Stores data as vertices (nodes) and edges (relationships).
  • Offers low-latency traversal of complex graphs.

Memory trick: Gremlin for graphs, SQL for documents, Cassandra for columns, Table for keys.

More Describe how to work with non-relational data on Azure questions