Azure table storage store multiple types

后端 未结 1 1452
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-19 04:58

What do you recommend in the following scenario:

I have an azure table called Users where as columns are:

  • PrimaryKey
  • RowKey
  • Timestamp
1条回答
  •  爱一瞬间的悲伤
    2021-01-19 06:00

    Your understanding is completely correct. Having the tasks split into 2 separate tables would mean 2 separate queries thus 2 transactions (let's keep more than 1000 entities out of equation for now). Though transaction cost is one reason to keep them in the same table, there are other reasons too:

    • By keeping them in the same table, you would be making full use of schema-less nature of Azure Table Storage.
    • 2 tables means 2 network calls. Though the service is highly available but you would need to take into consideration a scenario when call to 1st table is successful however call to 2nd table fails. How would your application behave in that scenario? Do you discard the result from the 1st table also? By keeping them in just one table saves you from this scenario.
    • Assuming that you have a scenario in your application where a user could subscribe to both Task 1 and 2 simultaneously. If you keep them in the same table, you can make use of Entity Group Transaction as both entities (one for Task 1 and other for Task 2) will have the same PartitionKey (i.e. User Id). if you keep them in separate tables, you would not be able to take advantage of entity group transactions.

    One suggestion I would give is to have a "TaskType" attribute in your Tasks table. That way you would have an easier way of filtering by tasks as well.

    0 讨论(0)
提交回复
热议问题