I'm a new comer to DB design. I'm attempting to write a game (4 gamers max) and was attempting to develop a method to communicate moves among one another. I'm utilizing a DB with this according to suggestions on stackoverflow.

My issue is this - When player A constitutes a move that move needs to be read by B,C and D. So the truth that A made the move must be conveyed to B,C and D. I'm doing the work the next way. Please let me know if there's an easy method to get it done. In my experience it appears incorrectly and extremely flaky.

I've got a table using the following fields -

gameId, userMove, flagA, flagB, flagC, flagD

Then when A helps make the move I write amongst other things - (flagA=, flagB=1, flagC=1, flagD=1)

When B,C or D read A's move they decrement their corresponding flag.

A won't update the table unless of course all flags are .

Same factor occurs when others make their moves.

Comments? There needs to be an easy method with this. The items I'm seeing wrong here -

  • I'm looping on the choose until all flags are for any
  • I'm looping on the choose before the flag for that corresponding user is placed to see the move.

That's lots of server load and client timeouts I have to be worried about.

I really hope I've been in a position to explain my problem clearly. Please request questions as needed.

Any assistance is appreciated.

EDIT: The overall game is internet based (runs inside a browser) and i'm using php for that server side development therefore i cannot make use of an in-memory cache though I'd have loved to achieve that if at all possible.

Thanks, - Pav

When the gamers of the game is going to be getting together with one game server throughout just one game session, it appears like you can preserve everything condition in memory.

Databases are ideal for durable storage of information with guarantees for atomicity, consistency and integrity. However, you do not appear to require these features for that temporal condition that you're explaining.

If flagA,B,C and D are bits you may consider putting all of them into one column and dealing with that column as a little mask.

This can allow one column to manage all flags. Celebrate your chooses and updates considerably cleaner.

Educate yourself on using bitmasks here:

Have you thought about usng personal files to keep the data?