Azure Storage Tables Data Model

Azure Table Storage Data Model

Azure Table Storage is a NoSQL key-attribute store that lets you store large amounts of unstructured and semi-structured data. The data model is designed for massive scale and simplicity. It consists of the following core components:

Entities

An entity is the basic unit of storage in Azure Table Storage. It's analogous to a row in a database table. Each entity is uniquely identified by a PartitionKey and a RowKey. An entity can have up to 252 properties, in addition to the PartitionKey and RowKey.

Properties are name-value pairs. Property names are strings, and values can be of any of the following Azure Table Storage data types:

Tables

A table is a collection of entities. Tables do not enforce a schema, meaning that different entities within the same table can have different sets of properties. However, all entities in a table must have the same PartitionKey and RowKey properties.

A table is identified by its name, which must be unique within a storage account.

PartitionKey and RowKey

Every entity in Azure Table Storage must have two required properties:

The combination of PartitionKey and RowKey must be unique for every entity within a table.

Example:


{
    "PartitionKey": "Customers",
    "RowKey": "123",
    "Email": "jane.doe@example.com",
    "FirstName": "Jane",
    "LastName": "Doe",
    "OrderCount": 5,
    "LastOrderDate": "2023-10-27T10:00:00Z"
}
            

Schema Flexibility

One of the key advantages of Azure Table Storage is its schema flexibility. You do not need to define the schema for a table upfront. You can add or remove properties from entities dynamically. This makes it ideal for scenarios where data structures may change frequently or are highly variable.

However, this flexibility comes with a caveat: when you query an entity, you receive all its properties. If an entity has many properties, the payload can become large. It's good practice to design your entities to include only the necessary properties for common query patterns.

Entity Group Transactions

Azure Table Storage supports entity group transactions (EGTs), which allow you to perform operations on multiple entities within the same PartitionKey atomically. This guarantees that either all operations succeed or none of them do, ensuring data consistency for related entities.

Supported Data Types

Azure Table Storage supports a rich set of primitive data types for entity properties. For a comprehensive list and details, please refer to the official Azure documentation on supported data types.

Summary Table

Component Description Key Characteristics
Entity A row of data. Max 252 properties + PartitionKey + RowKey.
Table A collection of entities. Schema-less. Identified by name.
PartitionKey Groups entities by logical partition. String. Crucial for performance and EGTs.
RowKey Uniquely identifies an entity within a partition. String. Part of the entity's unique ID.

Understanding the data model is fundamental to effectively designing and utilizing Azure Table Storage for your applications.