question

Andres Urquijo avatar image
Andres Urquijo asked

Proper distribution of data in SharedDataGroups

Hello! 

I was wondering what the most appropriate approach would be for distributing my data in share data groups.
Some context for my application. We have classrooms, with students and teachers. The students attend a fixed number of lessons. For each lesson and student we need to store some variables. This data should be editable by teachers. 

I see 3 possible approaches: 

1) Create 1 shared data group per usage group and within each group, 1 key value pair per variable. In this manner each student user would have several shared data Groups associated. "[[PlayFabID]]_Lesson1", "[[PlayFabID]]_Achievements", etc.

2) Create a single shared group per student. Each key has more distinctive key names such as: "Lesson1_Grade".

3) Create a single shared group per student, with a single key value pair per logical object. For instance the data for a lesson could be stored with a key "Lesson1_Data" with a value "Grade:A ~ Assignment_A:Socrates always liked dancing the macarena, but...."

I am currently pursuing option 1, to follow separation of concerns. This helps me keep my data organized. But it requires me to have a lot of shared data groups, and make several API calls to load all of the data. In fact, it seems this approach might be downright impossible, as each user currently would need about 40-50 small shared data groups. And I read there is a 10 groups per user limit.

With this in mind, are there any particular recommendations I should follow on how to use shared data groups?

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

brendan avatar image
brendan answered

Actually, it sounds like you don't need Shared Group Data at all. The idea of Shared Group Data is to be able to have a small number of players share some data, with each player writing to one or more distinct keys in that data set (so that there's no collision risk). And even then, when I say "writing" I really mean "writing via Cloud Script". But in general, this is because there's no one user who is the specific "owner" of the data, as with a Guild system or turn-based multiplayer game session.

In your case, all the data is specific to the users - the classes they're taking, etc. - and the only people who require access are the user and the teacher. Since the data is for the user, it should just be stored in User Read Only Data, so that you can update it via Cloud Script (and so, prevent a hacked client from writing whatever it wants to). Within that, I would probably store all the data about a given lesson as a single Key/Value pair. The teachers would then have data about which users are their students, so that they could reference that to find their students and read their data. Though if teachers can hand-off a full "class" of users, it might be better to store that as Shared Group Data that only teachers access, and can re-assign to one another.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Andres Urquijo avatar image
Andres Urquijo answered

Thank you very much for your response. Your suggestions make a lot of sense! I suppose I was trying to avoid using Cloud Script, and overlooked the possibility of being able to edit user data from other users with this.

Another reason why I was separating data into different key value pairs, was to be able to make small writes without having to rewrite a big package of data. For instance writing the value for "Assignment002_Grade" without having to rewrite the rest of the lesson data. With Cloud Script I can see how I can just send this particular value on it's own, and have the CloudScript take care of replicating the previous state of the rest of the data package for the lesson. (unless there is a way of injecting values that I do not know about)

Is there a particular reason for preferring the use of a single/few key value pair, as opposed to many?

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

brendan avatar image
brendan answered

Actually, whether you divide up the data depends on a few factors. I was thinking your total data for the lesson would be relatively compact (I wasn't actually thinking of rolling up everything for a grade), so that was my suggestion. But if that's more than a couple of KB, it may be better to divide it up. If I knew more of the specifics of your data format and content, that would help with giving more specific advice. How do the "grade" and "lesson" data break down? Is there any portion which is static, and so could be stored in Content or Title Data?

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.