Azure Cosmos Db Flashcards
The e-commerce application has a requirement to support a shopping basket.
Customers can add and remove products, and any discounts (like buy one get one free) need to be kept in the basket.
The sales team wants the flexibility to offer different kinds of discounts, and to add or remove different product categories.
Choose the API that best supports the requirements.
A: Core (SQL) B: MongoDB C: Cassandra D: Azure Table Storage E: Gremlin (graph)
A: Core (SQL)
MongoDB might be a good second choice due to the document nature, but Core (SQL) is the best choice as there is no need to support existing MongoDB data or an existing application.
Cassandra isn’t a good fit as flexibility is needed - There isn’t a fixed schema,
Table Storage won’t work as this isn’t a simple key-value pair.
Gremlin is not correct as there is no requirement to store relationships or metadata on those links between items.
The risk department has asked if the new project could implement some form of fraud detection and prevention.
The guidance is that the fraud system would need to be able to track the relationship between customers, payment types, billing and delivery addresses, IP address, geolocation, and past purchase history.
Anything that doesn’t fit into normal behaviour should be flagged.
Choose the API that best supports the requirements.
A: Core (SQL) B: MongoDB C: Cassandra D: Azure Table Storage E: Gremlin (graph)
E: Gremlin
Complex relationships, and needed to store metadata against them is best supported by a graph mode of data.
None of the other solutions offer this
The sales team would like to offer a chat feature for customers.
Messages will have a fixed number of characters and be simple.
The schema is fixed, and the sales team has an existing chat app for which they have built up many CQL statements for creating reports.
They would like to reuse them if possible.
Choose the API that best supports the requirements.
A: Core (SQL) B: MongoDB C: Cassandra D: Azure Table Storage E: Gremlin (graph)
C: Cassandra
The need to reuse existing CQL queries means that Cassandra is the best choice for in this scenario.
Core (SQL) would be a good second choice for this scenario.
What is the Default API for Cosmos DB
Core (SQL) is the default API for Azure Cosmos DB, which provides you with a view of your data that resembles a traditional NoSQL document store.
You can query the hierarchical JSON documents with a SQL-like language.
Core (SQL) uses JavaScript’s type system, expression evaluation, and function invocation.
Which API would be used for this query syntax?
db.Items.find({},{productName:1,_id:0})
Mongo DB
What Cosmos DB Api would you use to provide a Graph like view of data in your database?
Gremlin (graph) API
Remember that at the lowest level, all data in any Azure Cosmos DB is stored in an ARS format.
A graph-based view on the database means data is either a vertex (which is an individual item in the database), or an edge (which is a relationship between items in the database).
The marketing team wants to be able to offer additional product recommendations while customers are browsing products on your e-commerce site.
For example, the team would like to provide suggestions like, “people who bought this product also bought that product”, and “people who viewed this product also are viewing that product.”
The products that are recommended first should be your most popular products, therefore a method needs to be provided that will enable ranking the relationships between products.
You decide tom implement a relational database using the SQL (Core) API
Would this solution meet the requirements?
No
It would be possible to model the relationship data in a NoSQL database; however, the lack of native queries that can answer the question, “How is this item related to that item?” means that this API isn’t the best choice.
The data store needs to be able to assign weight values to the relationships between products.
For example, you might store a count of the number of times that a relationship occurs.
With that in mind, each time that a person buys “Product A” and “Product B”, the relationship link between these two products needs to be incremented. This relationship counter is meta-data.
A graph database is the perfect fit to model this kind of data. Gremlin, the graph query language, will support the requirements.
The operations team has been using an app that uses an existing MongoDB database to process purchase orders. The database captures data throughout the order process, including failed and partial orders, fulfillment data, and shipping status.
MongoDB was chosen because each supplier wanted their orders in different formats. In addition, each supplier returns different meta-data.
The volume of these suppliers has increased exponentially as your company has rolled out drop shipping.
The operations team wants to keep access to this data, and continue to use their current purchase order system with as few code changes and as little downtime as possible.
You decide to implement a MongDB API
Would this solution meet the requirements?
Yes
The operations team has semi-structured data that needs the flexibility to store many different supplier order formats.
Both Core (SQL) and MongoDB are good options.
However, your operations team wants to reduce downtime during their app migration, so your best bet would be to find a way to allow your operations team to continue to use the MongoDB wire protocol.
Azure TableAPI isn’t a good choice for this scenario, and should only be used to allow existing apps that are based on the Table API access to Azure Cosmos DB.
Cassandra API isn’t a good choice due to the existing MongoDB database, and the requirement to import and reuse application code.
Gremlin API isn’t a good choice because the data isn’t graph based.
Your web analytics team is using a third-party web analytics application that uses a Cassandra database, and the team has experience writing Cassandra Query Language (CQL) queries to produce their own reports.
You decide to use Mongo DB api
Would this solution meet the requirements?
No
The flexibility of a document-based data store is not enough of a reason to use MongoDB.
Since the web team is already using their Cassandra-based application, and because of their prior experience using the Cassandra Query Language (CQL) for some of their reporting, Cassandra is the right choice for this scenario, although Core (SQL) is still a close second choice.
All of the requirements for your web analytics application can be satisfied by Core (SQL), which makes your decision difficult when choosing between Core (SQL) and Cassandra.
Azure TableAPI isn’t a good choice for this scenario, and should only be used to allow existing apps that are based on the Table API access to Azure Cosmos DB.
Gremlin API isn’t a good choice because the data isn’t graph based.
The project architect has asked you to determine the advantages of moving data from an existing Azure Table Storage data set.
The project architect found an existing 10 TB database that one of the project teams uses to store data from a legacy Internet of Things (IoT) application, and the data is seldom updated.
Moving your database from Azure Table Storage into Azure Cosmos DB with a low throughput could have considerable cost savings, since Table Storage is charged on the size of data rather than how often it is accessed.
Should you recommend moving to Azure Cosmos DB?
No
The IoT data consists of key-value pairs with no relationship information, and the existing dataset is currently deployed in Azure Table Storage.
The best practice is to use Core (SQL) for new projects, as it has more features than the Azure Table API.
However, to reduce downtime during your migration to Azure Cosmos DB, you might want to consider using the Table API for now, and switch to Core (SQL) sometime in the near future.
Core (SQL) This API would be the best choice if you were designing a new system; however, since this scenario consists of a legacy application with a large existing Azure Table Storage dataset, the Azure Table API is the correct choice.
Gremlin This API isn’t a good choice because this scenario doesn’t need to process graph-based data, and because of the requirements to import and reuse application code.
MongoDB This API isn’t a good choice because of the existing Azure Table Storage database, and because of the requirements to import and reuse application code.
Cassandra This API isn’t a good choice because of the existing Azure Table Storage database, and because of the requirements to import and reuse application code.
True or false: the benefits of writing to multiple regions are decreased latency, unlimited scaling potential, and improved availability.
True
Writing to multiple regions has many performance benefits. For example, the latency for write operations is less than in non-multi-master accounts.
What is the default conflict-resolution policy in a multi-master account?
A: Last-Writer-Wins
B: A custom user-defined procedure
A: Last Writer Wins
Conflict resolution is built-in to Azure Cosmos DB and is performed on the server, inside the database engine. Last-Writer-Wins is the default policy.
User-defined procedures are supported, but they are not the default mechanism for handling conflicts.
Which consistency level is most appropriate for the user data in an e-commerce database? Users need to ensure that their orders contain all the items they placed in their basket.
A: Strong B: Bounded Staleness C: Session D: Consistent Prefix E: Eventual
C: Session is the best consistency setting for user data that contains shopping basket information. Session consistency will ensure that every item the user put in their basket is displayed when they review their basket.
Strong consistency is not available for databases replicated in multiple regions.
Bounded Staleness may result in only some of the users items being displayed in their basket.
Consistent Prefix could result in only some of the users items being displayed in their basket.
Eventual consistency might result in a situation in which a shopping basket didn’t display all the items the user had placed in it.
Which consistency level consumes the least amount of request units per operation?
A: Strong B: Bounded Staleness C: Session D: Consistent Prefix E: Eventual
Eventual
The cost of a read operation with eventual consistency consumes the least number of request units per seconds.
What is Strong consistency
Strong consistency offers a linearizability guarantee with the reads guaranteed to return the most recent version of an item.
Strong consistency guarantees that a write is only visible after it is committed durably by the majority quorum of replicas. A write is either synchronously committed durably by both the primary and the quorum of secondaries, or it is aborted. A read is always acknowledged by the majority read quorum, a client can never see an uncommitted or partial write and is always guaranteed to read the latest acknowledged write.
You can have an Azure Cosmos account with strong consistency and multiple write regions. However, the benefits such as low write latency, high write availability that are available to multiple write regions are not applicable to Cosmos accounts configured with strong consistency, because of synchronous replication across regions. For more information, see Consistency and Data Durability in Azure Cosmos DB article.
The cost of a read operation (in terms of request units consumed) with strong consistency is higher than session and eventual, but the same as bounded staleness.