Domain 3 of 3

Implement AI and analytics capabilities in database solutions

Domain · 22.5% of the DP-420 exam

One operational store, three new readers

A bike retailer's Azure Cosmos DB for NoSQL account already serves its orders. Now a shopping assistant must answer "Which bikes suit rough trails?", remember that this customer rides to work, and feed a revenue report. Each requirement adds a new reader of the same operational data ("reader" is this guide's word for whoever needs the data, not a Microsoft term): a language model (large language model, LLM) that needs the items relevant to one question (AI retrieval), an agent that needs its own earlier conversations (agent memory), and an analyst who needs totals across every item (operational analytics). Microsoft frames the role the same way, with Azure Cosmos DB as the system of record for agent memory, conversation state, retrieval indexes, grounding data, and application data. The classic trap: assuming the model fetches data itself. It does not, and it remembers neither prompts nor its own generated answers (completions): LLMs don't retain any context between prompts and completions, so your application retrieves the relevant items and passes the retrieved data to an LLM. A report, by contrast, reads a copy in OneLake, Microsoft Fabric's data lake, not the live database.

Three subtopics, one per reader

This domain carries 20–25% of the exam (the header's 22.5% is that range's midpoint), and its three subtopics move from finding relevant items, to remembering conversations, to reporting on everything. Design and implement AI retrieval sets up search on a container: full-text search matches words and ranks them with BM25 (Best Matching 25); vector search measures the distance between the data vectors and your query vector, where each vector embedding is the numeric array an embedding model returns and your application stores in the item (unrelated to embedding in the data-modeling sense of nesting related data); and hybrid search combines vector search with full-text search scoring by using the Reciprocal Rank Fusion (RRF) function. Retrieval-augmented generation (RAG) then passes the best matches to the model as grounding data. Design and implement agent memory stores applies the same search functions to the agent's own history, a thread (one conversation) made of turns (one exchange each): how to partition and model it, keep short-term and long-term memory, persist a session, and reuse earlier completions through a semantic cache, which uses prior user prompts and LLM completions to address similar user prompts by using vector similarity search and is unrelated to the integrated cache covered in Optimize and remediate database performance. Design and implement operational analytics on Azure Cosmos DB chooses between Azure Cosmos DB and Cosmos DB in Microsoft Fabric (Cosmos DB in Fabric), which uses the same engine, same infrastructure as Azure Cosmos DB for NoSQL, but is tightly integrated into Fabric. The choice decides how data reaches OneLake: a Cosmos DB in Fabric database is mirrored into OneLake automatically, while an Azure Cosmos DB database gets there once you enable mirroring on it. Either way, the data is read on one of two paths: the OneLake path reads the OneLake copy with T-SQL or Spark, and the connector path uses the Cosmos DB Spark connector, which connects directly to the Cosmos DB endpoint to perform operations.

When two answers both work, read less from the live database

Across all three subtopics, the better answer usually narrows each read to the data the requirement needs and keeps heavy reads off the live database. In AI retrieval that means always bounding a vector query with a TOP clause, because without one the vector search tries to return many more results, and the query costs more request units (RUs) and has higher latency, and setting vectorIndexShardKey, the setting on a DiskANN index (a vector index type) that names an item property, so that a tenant-filtered search uses one DiskANN index for each unique value of that property. In agent memory it means a partition key such as /threadId when most queries target a single conversation, and in operational analytics it means reading the OneLake copy, which mirroring fills without any performance impact on your transactional workloads or consuming Request Units (RUs). The connector path is the deliberate exception: choose it when results must be written back to the live database, knowing that write operations to Azure Cosmos DB will consume request units (RUs).

Three readers of operational data, and the subtopic that covers each

Reader and jobThe question it asksKey building blocksDrill into
A language model: AI retrievalWhich items are relevant to this one question?Full-text, vector, and hybrid search over items that hold text and a vector embedding; RAG grounding dataDesign and implement AI retrieval
An agent: agent memoryWhat did this conversation or user say before?Threads and turns, short-term and long-term memory, a persisted session, a semantic cacheDesign and implement agent memory stores
An analyst: operational analyticsWhat do all the items add up to, without slowing the application?The OneLake copy (mirrored automatically from Cosmos DB in Fabric, or by enabling mirroring on Azure Cosmos DB), the OneLake path and the connector pathDesign and implement operational analytics on Azure Cosmos DB

Decision tree

Agent recalls its ownturns or completions?YesAgent memoryNoLanguage model needsrelevant items?YesAI retrieval(grounding data)NoAnalyst needs totalsacross every item?NoOutside thisdomainYesResults written backto the live database?YesConnector path(consumes RUs)NoOneLake path(reads the copy)Agent memory reuses thesame search functions

Subtopics in this domain