In this very short blog post, we ll see an introduction on how to query Cosmos DB with the SQL API. Now SQL is just like another language when you want to get data out of the database, but the problem that arises is that it a relational database whereas CosmosDB is a NoSQL database.
What is LINQ?
Linq provider translates the language-integrated queries written in C# into Cosmos DB SQL. It is good to use Linq for such query translation however this also eventually is an SQL only.
So, to do this, The Cosmos DB team answers with the options below:
- Using the dot notation to navigate to the path to properties of the nested objects, and arrays.
- The second technique is, just like the tables are joined using Inner Join inside a relational database, we can use Intra-document join to combine the nested elements under a parent element.
For an example, let us consider this:
Doesn’t it look very much like a SQL query?
In this blog post, we saw an introduction on querying CosmosDB with SQL API. We covered how we can adapt to NoSQL CosmosDB and work with it using the SQL API which is used for relational databases ironically.