Tuesday, February 19, 2013

Azure Table Storage - Dynamic Columns

The Windows Azure Table storage service stores large amounts of structured data in the form of entities ( An entity contains a set of properties).
It's a NoSQL kind of datastore and are ideal for storing structured, non-relational data.

Each entity can hold up to 255 properties (including 3 required properties) and the combined size cannot exceed 1 MB.

The three required properties are
"PartitionKey"
"RowKey"
"timestamp"

So, effectively that leaves us with 252 properties to work with.
Entities map to C# Objects. So, programmatically you would declare a class that inherits from "TableEntity".

eg.,
public class CustomerEntity : TableEntity
{
    public CustomerEntity(string lastName, string firstName)
    {
        this.PartitionKey = lastName;
        this.RowKey = firstName;
    }

    public CustomerEntity() { }

    public string Address { get; set; }
   
    public string Email { get; set; }
   
}


If you would like to keep your schema design dynamic as azure table storage supports, there are couple of ways you could do to achieve that.

Here are some links that help you solve it:

http://blogs.msdn.com/b/avkashchauhan/archive/2011/03/28/reading-and-saving-table-storage-entities-without-knowing-the-schema-or-updating-tablestorageentity-schema-at-runtime.aspx

http://developenator.blogspot.in/2011/09/dynamic-type-factory-for-azure-table.html

http://blog.tylerdoerksen.com/2011/10/23/intermediate-table-storage-custom-columns/

http://ruiromanoblog.wordpress.com/2009/05/15/azure-table-storage-with-dynamic-entities-objects/


No comments:

Post a Comment