Reputation: 4721
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.
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; }
}
Upvotes: 0
Views: 264
Reputation: 4656
Your design looks fine I think. It depends on how you are going to retrieve them. In your example you have a blog system so I assumed you need to retrieve your blog alone with all its comments (and sub-comments as well), then you could have blog id as the partition key and retrieve all comments in one query and it also ensure all comments under the same blog are stored in the same data cluster in azure data center with max performance.
If you need more performance I'd like suggest you to store author name as well, to reduce the join operation in your application layer.
Upvotes: 1