Azure Storage, Comos DB Flashcards
What is an Azure Cosmos DB account?
Needed to begin using Azure Cosmos DB,
The API determines the type of account to create. Azure Cosmos DB provides five APIs: Core (SQL) and MongoDB for document data, Gremlin for graph data, Azure Table, and Cassandra.
Currently, you must create a separate account for each API
Contains a unique DNS name that gets appended to documents.azure.com
Acts as an organizational entity for your databases. Azure Cosmos account –> Databases –> Containers (tables) –> Stored procedures, triggers, user-defined functions, etc.
True or False? Azure Cosmos DB provides different data models
True:
SQL API, MongoDB, Cassandra, Azure Table and Gremlin (graph)
To minimize Cosmos DB latency, what can you do on creating Azure Cosmos DB Account?
Select a location thats near to customers
True or False? In Azure Cosmos DB, you provision throughput for your containers to run writes, reads, updates, deletes, and queries
True
How is Azure Cosmos DB measuring throughput?
With request unit (RU). Request unit usage is measured per second, so the unit of measure is request units per seconds (RU/s)
True or False? You must reserve the number of RU/s you want Azure Cosmos DB to provision in advance, so it can handle the load you’ve estimated, and you can scale your RU/s up or down at any time to meet current demand.
True
True or false: The number of RUs used for a given database operation over the same data varies over time.
False, Azure Comos DB guarantees that the same query on the same data is consistent.
Which of the following options affects the number of request units it takes to write a document?
Size of the document
Item property count
Indexing policy
All of the above
All of the above
Which of the following statements is false about Request Units (RUs) in Azure Cosmos DB?
The cost to read a 1 KB item is approximately one Request Unit (or 1 RU).
Requests are rate-limited if you exceed the number of provisioned RU.
Once you set the number of request units, it’s impossible to modify this number.
If you provision ‘R’ RUs on an Azure Cosmos container (or a database), Azure Cosmos DB ensures that ‘R’ RUs are available in each region associated with your account.
Once you set the number of request units, it’s impossible to modify this number.
Its always possible to change them from 400 to 250000.
In Azure Comos DB, What is a partition strategy?
As your provisioned throughput or data size grows, Azure Cosmos DB will automatically create new physical partitions by splitting existing ones.
The throughput you select gets evenly distributed across physical partitions.
You want to choose a partition key that evenly distributes consumption across the physical partitions.
True or False? A partition key defines the partition strategy, it’s set when you create a container and can’t be changed
True
In Azure Comos DB, what is a partition key?
A partition key is the value by which Azure organizes your data into logical partitions. All the items in a logical partition have the same partition key value.
Read Again:
When you’re trying to determine the right partition key and the solution isn’t obvious, here are a few tips to keep in mind.
Don’t be afraid of choosing a partition key that has a large number of values. The more values your partition key has, the more scalability you have.
To determine the best partition key for a read-heavy workload, review the top three to five queries you plan on using.
The value most frequently included in the WHERE clause is a good candidate for the partition key.
For write-heavy workloads, you’ll need to understand the transactional needs of your workload, because the partition key is the scope of multi-document transactions.
OK
True or false: You can add a partition key to an Azure Cosmos DB container after it has been created.
False, You can set the partition key only when the container is created.
Your organization is planning to use Azure Cosmos DB to store vehicle telemetry data generated from millions of vehicles every second. Which of the following options for your Partition Key will optimize storage distribution?
Vehicle Model
Vehicle Identification Number (VIN) which looks like WDDEJ9EB6DA032037
Vehicle Identification Number (VIN)
True or False? Core (SQL) API is the default Api for Azure Cosmos DB
True
True or False? Core (SQL) API: You can query hierarchical JSON documents with a SQL-like language
True
True or False? at the lowest level Cosmos DB Stores Data in ARS Format (atom-record-sequence) and APIs are just ways to access and modify those.
True
Best API for creating projects from Scratch using Cosmos DB?
Core (SQL)
Best Approach when there is existing DB?
Use the appropriate technology, like Mongo or Cassandra or Gremlin. What ever fits best in the project environment
What API fits best for Azure Comos DB when Data consists of Key-value pairs
Earlier Redis and Table API, but today best fit is Core (SQL) because of richer query experience with improved indexing
What should be the key requirement when deciding for Gremlin
Gremlin (graph) is good when Relations between items have to be made. Like “How is this item related to that item”
A good example is a shop recommendation engine.
How to determine the best fiting Comos DB Api based on a Problem description?
1) Is data unstructured?
2) Is there any existing technology used? If so, probably use even if there is a better choice to reuse code / reduce migrating time because of tech shift
3) Is migration downtime a issue? If not, prefer the better choice instead of 2)
What is CQL referring to?
Cassandra Query Language
When to use Azure Table?
When migrating from earlier Apis like Azure Table Storage or Redis. Then this is preferred instead of Core (SQL) when no downtime is wanted
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.
This type of data is modeled best by documents. Core (SQL) is the best choice for a new system.
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 behavior should be flagged.
Complex relationships, and needed to store metadata against them is best supported by a graph mode of data.
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.
The need to reuse existing CQL queries means that Cassandra is the best choice for in this scenario.
True or False? Azure Cosmos DB provides the Data Explorer tool in the Azure portal that you can use to perform all these operations: adding data, modifying data, and creating and running stored procedures.
True
True or False? The database account name must be unique across all Azure Cosmos DB instances.
True
What is the only required clause in a SQL query?
SELECT
FROM
WHERE
SELECT is the only required clause in a query.
Which query will get an ordered list of product IDs and descriptions, starting with the largest product ID and ending with the smallest product ID?
1) SELECT p.productId FROM Products p ORDER BY p.productId ASC
2) SELECT p.id FROM Products p ORDER BY p.productId DESC
3) SELECT p.productId, p.description FROM Products p ORDER BY p.productId DESC
3) SELECT p.productId, p.description FROM Products p ORDER BY p.productId DESC
What does ACID mean?
Atomicity, Consistency, Isolation, Durability.
Transaction in a typical database can be defined as a sequence of operations performed as a single logical unit of work. Each transaction provides ACID property guarantees.
Atomicity: guarantees that all the operations done inside a transaction are treated as a single unit
Consistency: data is always in a valid state across transactions
Isolation: no two transactions interfere with each other
Durability: any change that is committed will always be present.
True or false? Stored procedures are written in JavaScript and are stored in a container on Azure Cosmos DB
True