Overview of Azure Cosmos DB Table API
The Azure Cosmos DB Table API is a NoSQL key-value store that supports schemaless data. It is designed for applications that need a highly scalable and globally distributed data store with low latency. The Table API is a great choice for applications that require the simplicity and flexibility of a key-value store while benefiting from the advanced features of Azure Cosmos DB.
What is the Table API?
The Table API in Azure Cosmos DB is built on the foundation of Apache Cassandra. It provides a familiar interface for developers who have worked with the Azure Cosmos DB Table API (formerly DocumentDB Table API) or Azure Table Storage. It allows you to store and query large amounts of structured, semi-structured, and unstructured data in a document database.
Key Features:
- Global Distribution: Distribute your data across any number of Azure regions with Azure Cosmos DB's global distribution capabilities.
- Scalability: Independently scale throughput and storage across your entire database.
- Low Latency: Achieve single-digit millisecond latency for reads and writes.
- Schema Agnostic: Store data without predefining a schema, allowing for flexible development.
- Indexing: Automatic indexing of all properties in your data.
- ACID Transactions: Support for strong consistency and ACID transactions.
- Enterprise-Grade Features: Built-in high availability, disaster recovery, and security.
Use Cases
The Table API is ideal for a variety of scenarios, including:
- Internet of Things (IoT): Storing time-series data from IoT devices.
- Web and Mobile Applications: Managing user profiles, session data, and content.
- Gaming: Storing player data, leaderboards, and game state.
- E-commerce: Handling product catalogs, order history, and shopping carts.
- Big Data Analytics: Providing a scalable backend for data processing pipelines.
Getting Started
To start using the Table API, you need to create an Azure Cosmos DB account and then create a Table API database. You can then use various SDKs to interact with your data.
Data Model
In the Table API, data is stored in tables. Each table contains entities, and each entity is a collection of properties. Properties are key-value pairs, where keys are property names (strings) and values can be one of several supported data types.
- Partition Key: A required property that determines the partition where an entity is stored. It significantly impacts scalability and performance.
- Row Key: A required property that, along with the partition key, uniquely identifies an entity within a table.
Learn more about data modeling best practices.
Querying Data
You can query your data using a rich query language. The Table API supports filtering, sorting, and projecting properties. Queries are typically optimized when they include the partition key and row key.
// Example query (conceptual, syntax may vary by SDK)
SELECT * FROM c WHERE c.PartitionKey = 'user123' AND c.RowKey = 'profile'
Explore different querying techniques.
Migration
If you have existing data in Azure Table Storage or other NoSQL databases, the Table API offers tools and guidance for seamless migration. This allows you to leverage the advanced features of Azure Cosmos DB without a complex re-architecture.
See the migration guide for detailed instructions.
Next Steps
Continue your learning journey by exploring the following topics: