question

brendan avatar image
brendan asked

Database Structure

Saifuddinazhar
started a topic on Thu, 20 August 2015 at 9:09 PM

I am an Unity Unity Programmer. I used to use parse db before and familiar with NoSQL database. At the current project I try to use playfab but I am still very confused about the structure of database in playfab. Basicly, I have two tables :

1) TableMonster
TableMonster contain all monsters including it basic atributes.

[
    {
        "id":"1",
        "name":"Agnito",
        "attack":"100",
        "defense":"80"
    },
    {
        "id":"2",
        "name":"Pico",
        "attack":"20",
        "defense":"50"
    }
]

2) TableUser
TableUser contains all users data. Every user has ownedMonsters which contains all monsters owned by user.

[
    {
        "name":"james",
        "ownedMonsters":[
            {
                "id":"1",
                "monsterId":"2",
                "level":"10"
            }
        ]
    },
    {
        "name":"michael",
        "ownedMonsters":[
            {
                "id":"1",
                "monsterId":"2",
                "level":"3"
            }
        ]
    }
]

ownedMonsters contain some jsonOwnedMonster which has 3 attributes :

  • id >> the id of ownedMonster

  • monsterId >> the id of monster related on TableMonster

  • level >> level of the monster. It's value must can be modified during gameplay

My Question :

  1. How to implement the database in playfab? Is it right if I write TableMonster at catalog?
  2. How to save ownedMonsters data in playfab? I try to use user inventory to save it but I didn't find playfab documentation about how to change 'level' attribute via PlayFabClientAPI. Are there another way to save it?
10 |1200

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

1 Answer

·
brendan avatar image
brendan answered

1 Comment
Brendan Vanous said on Sun, 23 August 2015 at 1:43 PM

While we've been having this conversation in email as well, I wanted to update this thread to ensure everyone has all the info:

Data in PlayFab is stored as string/string Key/Value pairs, in DynamoDB, using the various Data calls you can see in our Client, Server, and Admin APIs. In Unity C#, this is particularly easy, since even for a complex object, you can take the ToString from the JSON encoded data, and use that as the value (up to 128KB). That way, you can define any custom properties you want ("level", etc.) in your object.

And my recommendation would be not to store these creatures in the catalog, but rather in Title Data. If they're meant to be characters that the player unlocks, you can use our Character system for that (have a look at the Client and Server API sets).

Subsequently, your questions concerned (edited, to remove your game's specific details):

  1. Whether to use Character or Inventory for your monsters

  2. How to manage Guilds

  3. How to query for users meeting a certain criteria

(also editing the response for confidentiality of the title)

Which system to use will depend upon the specific of your needs. If you only need to query a few monsters at a time, you could potentially manage them as Characters. This would simplify the job of managing inventory separately for each monster, since characters can have distinct inventories. However, if you need to query data for all of them when loading the user account, you should really either choose to make them inventory or Shared Group Data records, so that you're not firing too many queries during the session. In that case, you would need to manage the monster inventories separately, but it would give you a great deal of flexibility.

Basically, the question is, what are the specifics of the data that you need for the monsters, and how often do you have to query for it? If your design works out such that the title only calls a backend API method once every few seconds on average (bursts are fine, so long as the average works out to be within reason), you'll be fine.

For guilds, yes, you can manage that via Shared Group Data, which provides you with the means to store any Key/Value pair data and make it available across any number of users. From my Xbox days, I'll say that there are a wide variety of interpretations of "Clan system", so knowing specifically what it is you want to accomplish would help in directing you here.

For queries, it sounds like you'll want to be able to do arbitrary queries against the data you're sending up. In that case, I would recommend getting set up with a Segment.com account, so that you can make use of any of the existing integrations they have, or pipe the data to your own database, for further analysis. We provide a number of reports and KPIs out of the box, and we'll be adding to this steadily over time, but for very game-specific data analysis like this, you'll want to go directly to the source data, which we make available.

Brendan

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.