I am creating a game and need to think of an underlying datamodel to use in a SQL database, running on InnoDB engine.
The main entities will be accounts, slots and characters. Every account has minimal one slot, possibly many more. And each slot can hold one character, but does not always have a character.
More information:
- Players will log into the game using the accounts.
- As time progresses they get more (character slots), starting off with one slot.
- In every slot they can put a character which may die at some point. If there is no character placed yet or a character is dead, then at that given time the slot will be empty.
- A player can control the characters individually, while being logged in through the main account.
Structure without relations:
- accounts (accountId, ...account data)
- slots (accountId, slotId, ...slot data)
- characters (characterId, ...character data)
Simple relations:
- account_slots (accountId, slotId)
- slots_characters (accountId, slotId, characterId)
Notes:
- accountId will be a unique key to accounts.
- slotId will not be a unique key to slots, it will be a number 1..maximum, however (accountId, slotId) will be unique.
- characterId will be a unique key to characters.
Do you think this is a correct model, even though it still needs ot be finetuned?
Now I want to add the correct relations between the tables with as few relations as possible, if a relation can be captured by adding a column to a table, then it should be done.
Regards.