Using Guid as partitionkey and reference other partitions
-
2012年4月11日 20:36
Hello,
I'm designing a new web app that will use table storage. basically a user will choose an event from a list and then be able to do different actions on an event he chooses.
Now to model this in Table storage I'm thinking of creating a table with all the events listed like
PK -guid (as string)
RK - guid (as string)
Name (displayname)
Now my point is that each RK used in the table will be used as partitionkey so every event get its own partition. There will be a lot of load on each event, so my point is to make each event a seperate partition.
Now my question is if this is a good way to design and define partitions?
Best regards
Rasmus
Developer
全部回复
-
2012年4月12日 7:52
Hi Rasmus,
This looks like a good design, if you can answer the following questions with yes:
- Will you always know the PK and RK? (ie: you won't need to search the other properties to find the records you need.) If the list of events and the list of users are stored in a DB / other tables, it's OK.
- Is the RK unique per partition (If you use the user ID for RK I suppose this is true. But what happens if a user wants to book 2 seats for the event. Is this possible?
Sandrino
Sandrino Di Mattia | Twitter: http://twitter.com/sandrinodm | Azure Blog: http://fabriccontroller.net/blog | Blog: http://sandrinodimattia.net/blog
- 已标记为答案 Rasmus Christensen 2012年4月13日 18:27
-
2012年4月12日 19:03
Hi Sandrino,
Thanks for the reply. For som of the basic I will know the PK and RK.
But after watching a webcast last night about choosing PK and RK it made me think even more about the queries which should be the driver for choosing the right keys.
So if I want to be able to list the events a user is participating in, I might also need to make partitions where I has the user as a RK, else I would need to scan partitions to find a users events.
So one way might be to create partition where the PK could be A, B, C, D and so on indicating the first letter og the user. Then each entity inside the table could have a RK which was a "userId + EventId". This would allow me to take a user who will login to the app, get his userid and name. By the first letter in the name find the partition, and then search in the partition for a RK which contains his userId. But how would I search if I have a RK which is a combination of two values? Is this a good approach?
/Rasmus
Developer
-
2012年4月13日 6:06
Hi Rasmus,
Let's say the event has an ID of 12345, and user X has an ID of 55555. Then you could have 2 things:
- 1 table called "EventUsers". PK = ID of the event. RK = ID of the user. This will give you a list of users for each event (if you know the ID of the event).
- 1 table called "UserEvents". PK = ID of the user. RK = ID of the event. This will give you a list of events for each user (if you know the ID of the user).
Having these 2 tables will allow you to easily create different views.
If you want to use composed keys with the ability to search, you should maybe look at this blogpost : http://blogs.southworks.net/fboerr/2010/04/22/compsition-in-windows-azure-table-storage-choosing-the-row-key-and-simulating-startswith/
Hope this helps.
Sandrino
Sandrino Di Mattia | Twitter: http://twitter.com/sandrinodm | Azure Blog: http://fabriccontroller.net/blog | Blog: http://sandrinodimattia.net/blog
-
2012年4月13日 18:28
Thanks once again.
I Also found this about composed keys http://www1.wintellect.com/Resources/Details/46
Developer

