0

I am currently working on a trading card game in the very early phase of it. I have a question about how to approach the database schema, excuse my terminology if I'm misusing it.

A little back ground on how it will be used. The client is coded in Unity3d and all commands will be passed to a server via php. The php will handle and logical functions for the game. This in theory should significantly reduce cheating. The server returns the state of the game back the client which displays the results to the user.

I am somewhat familiar with SQL and I am using MySQL for the database. I have read things about scalability issues with it. I'm not too concerned with it as I have no disillusions about have thousands of players and besides if it does I'll worry about that then.

My abridged database structure is as follows:

users -> userID(unique device ID) , name
card -> cardID, name, type, cost, image, rarity, attack, defense, description
tag -> tagID, name, description
ability -> abilityID, name
card_tag -> cardID, tagID
card_ability -> cardID, abilityID

I not sure how to structure the database for saving each individual user's info. I do at least know, or believe I do, what I require. The database should save each card they user has and what deck its currently in. I'm thinking of allowing 3 decks and an individual card may be apart of none or more of them. The cards themselves will be able to gain exp and levels. Also upon leveling up the card's stats and abilities may change. When a card levels up the users will be presented with different options to enhance it. So two of the same card leveled differently will have slight differences, example: one will have +1 attack the other may have +1 defense.

I was thinking a solution would to be create a table for each user to contain their card with the card experience, level, decks membership, and other things that are unique to it contained there. I can see this getting possibly getting out of hand.

Another possibility would be to have a very large table containing card instances and reference the user in it as well.

I'm sure there are other approaches as well, but you don't know what you don't know. Any help is very much appreciated!

Edit: The players will be able to take the cards they have and assign them into decks for grouping. A deck will consist of 60 or so cards, it will be the cards used while in gameplay. A small example: a user has cards A,B,C,D,E, and 2x of F. Deck one consists of cards A, B, C and F. Deck two of B, C, D, and F. While deck three consists of A,B, D, and 2x F.

3
  • please clarify what "deck" is
    – koriander
    Mar 7, 2014 at 19:30
  • Added clarification with an example above.
    – James
    Mar 7, 2014 at 19:50
  • are cards A from deck 1 and 3 really the same? i.e., level-up A in deck 1 applies to A in deck 3?
    – koriander
    Mar 7, 2014 at 20:26

1 Answer 1

0

You need at least, from what I can get from your description:

user_cards(userID, cardID, attack, defense)
user_decks_cards(userID, cardID, deck_no)
user_card_abilities(userID, cardID, abilityID)
3
  • Would this be a good solution with 500 rows in the card table and with 200+ users? How scalable is this setup, would it hold up with thousands of users each with hundreds of cards? Also, thank you for your quick response.
    – James
    Mar 7, 2014 at 19:59
  • in terms of scalability I'm sure it's not a problem. however, whether the design is the best one or not I can not be sure merely with the information you provide.
    – koriander
    Mar 7, 2014 at 20:28
  • forgot to mention, you'll need suitable indexing for performance
    – koriander
    Mar 7, 2014 at 20:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.