In the previous articles, we have seen how to query documents using the SQL API and how widely it is used. But then the question that arises is why do we still use other APIs if SQL APIs are so flexible to work with for any data type.
In this blog post, we will focus on comparing the differences between the SQL API and Table API.
The concept of containers in Cosmos DB using any API remains the same, with the only difference being in the name used to call that container. In the case of SQL API, it is called collection, however, table when using Table API.
Items
The SQL API calls the items as documents which come inside a collection. This basically means that the collection comprises of many documents with unique document IDs. In the case of Table API, it is called as Rows. So just like a collection contains many documents, a table contains various rows which are the items in that table and each row is indexed.
Partition Key
When choosing the partition key for the data, when using SQL API, we can actually use any of the attributes as the partition key. However, this is different when using the Table API. With Table API, we need to name the attribute to be used as PartitionKey.
SQL API:
{
category: “fruits”,
id: “apple”,
quantity: 30
}
Table API:

Unique Identifier
In the SQL API, the id that is used as a unique identifier is called RowKey when using the Table API. The other properties can be simply used as an arbitrary key-value pair.
CONCLUSION
In this blog post, we quickly saw the important differences between the SQL API that is widely used and the Table API that is most used when getting the data from Azure Table Data Storage to Cosmos DB Table API.
Leave a Reply