java - How to design Database for this situation? -
i'm working minimal game java , mysql. encountered difficulties how design tables correctly. need advices: let me specific, have 3 classes:
node
public class node { private integer id; private integer position; private integer foodtax; private boolean hastreasuremap; private integer currentplayer; // playerid
treasure
public class treasure { integer id; private integer position; // nodeid private integer goldvalue;
player
public class player { private integer id; private integer wealth; private integer strength; private integer start; private integer goal; private integer currentposition; // nodeid private integer currentgoal; // nodeid private vector<integer> path; private vector<integer> treasureids; private int currentmoveindex; graph<integer> telescope;
i'm newbie mysql, , database in general. think have use foreign key in case. however, i'm still vague how implement it. besides, there several constraints:
- treasure's position fixed.
- node position fix.
- only player position can changed.
- a node can have player @ time.( try make simple can, cause if there 2 players in same node, don't know how handle )
so foreign key here in opinion 'currentplayer' id of class node? please correct me if wrong. idea?
best regards, chan nguyen
it's still not clear you're trying store, have table nodes:
node id position foodtax hastreasuremap currentplayerid /*refers player table*/ treasure id nodeid /* refers node table*/ value player id /*unrelated fields such wealth, strength, start*/ position /*refers id in node*/ currentgoal /*refers id in node*/ playertreasures playerid /* refers player table*/ treasureid /* refers treasure table*/ paths nodeid /*refers nodeid - assume path made of nodes*/ sequenceinpath /*i assume ordering in path matters*/ playerid /*refers player owns path*/
...i have no idea telescope
for. again, suggestion might not work, i'm not sure you're doing data.
Comments
Post a Comment