I'm very new to Azure table storage, and the concept of a partition key is still an area where I'm not yet confident to know if I'm proceeding correctly. Below is my proposed solution for storing blog post comment data. I've commented everything so I hope my thought is self explanatory based on the code.
- Do the row and partition key look ok?
- Do I actually need a field called "CommentId?" (In the example I saw, there seemed to be no specific ID field as one would have in a traditional SQL store.
- What should the scope of a table be? (I currently envision one table for all comments across all blog posts.)
Thanks for any thoughts I may not have considered...
-Ben
public class CommentEntity : TableEntity
{
/// <summary>
///
/// </summary>
/// <param name="CommentId">Unique identifier for the comment</param>
/// <param name="ReferencedBlogPostId">Identifier representing the post which this comment references</param>
public CommentEntity(int CommentId, int ReferencedBlogPostId)
{
this.PartitionKey = ReferencedBlogPostId.ToString();
this.RowKey = CommentId.ToString();
}
public CommentEntity() { }
// public int CommentId { get; set; } (Moved to above constructor)
// public int ReferencedBlogPostId { get; set; } (Moved to constructor)
//If this is in reply to another comment, reference that CommentId here
public int ParentCommentId { get; set; }
//Time that the post was made
public DateTime PostedTime { get; set; }
//An Id value representing the author of the comment in another datastore
public int AuthorId { get; set; }
}