Question
You have a database named db1 in an Azure Cosmos DB for NoSQL account.
You are designing an application that will use db1.
In db1, you are creating a new container named coll1 that will store online orders.
The following is a sample of a document that will be stored in coll1.
```json
{
"customerId" : "bba6fe24-6d97-4935-8d58-36baa4b8a0e1",
"orderId" : "9d7816e6-f401-42ba-ad05-0e03de35c0b8",
"orderDate" : "2021-09-29",
"orderDetails" : []
}
```
The application will have the following characteristics:
- New orders will be created frequently by different customers.
- Customers will often view their past order history.
You need to select the partition key value for coll1 to support the application. The solution must minimize costs.
To what should you set the partition key?
- A. orderId
- B. customerId Correct
- C. orderDate
- D. id
Explanation
customerId has high cardinality, so writes from many customers spread evenly across partitions, and the frequent order-history query filters on one customer, so it stays in a single partition and avoids costly cross-partition queries. orderId or id would also spread writes but would turn every history lookup into a cross-partition query. orderDate would send all of a day's new orders to one hot partition.