Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8411887
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:32:18+00:00 2026-06-10T00:32:18+00:00

I have a game I’m writing using PHP. For the purposes of my question

  • 0

I have a game I’m writing using PHP. For the purposes of my question we can compare my game to “Words with Friends” on the iPhone, for those unfamiliar with the game it is an online/mobile scrabble game. The game consists of 3 major steps:

  • 1st two users decide to start a game.
  • 2nd, a new row is created within the database table “DATA” which
    holds the game data for the two users.
  • 3rd, and finally, the two are relocated to a new page where they play
    the game. When the game is over the row in the “DATA” table is
    deleted and wins/losses are saved and reflected in the “USER” table.
    Like Words with Friends, a user can have multiple ‘open games’ at any
    moment. Meaning they don’t have to finish one game before another is
    started.

Background: in the MySQL database I’ll have at least two tables one for generic player data labeled: USER and another to keep the stats of games currently in progress called: DATA. Each user will be given a unique 9-digit ID primary-key when they create an account.

I need some advice on best practices used to accomplish something like this. I had some ideas, fairly primitive in my opinion, they would work but I would like to use something more professional.

One of my ideas was to take the lower number of the two user’s IDs and concatenating it to the beginning of the larger one and save that in the database. An example. We have 2 users: adam and alan. Their IDs are 123456789 and 223456789 respectively. These two start a game which makes a new row in the DATA table where the GAMEID is equal to 123456789223456789. They play halfway through the game and sign out. The next day they try to start a new game. The database checks which user has a smaller ID and concatenates them together to check if a record of a game already exists. It notices the 123456789223456789 game already started and instead of creating a brand new game it brings them back to their game already in progress.

I feel this is certainly over kill and there should be a much easier way around this issue. Please I appreciate and suggestions or tips.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T00:32:19+00:00Added an answer on June 10, 2026 at 12:32 am

    A simple user_games table where you associate games with users would suffice. You can even add a flag for active or a datetime for last active at.

    CREATE TABLE user_games (
      user_id INT NOT NULL,
      game_id INT NOT NULL,
      UNIQUE KEY index_user_games_on_user_game (user_id, game_id),
      KEY index_user_games_on_game (game_id)
    );
    

    Don’t over-complicate this by making up keys that can’t be indexed properly. Indexes are what prevent your table from becoming an unqueryable mess. This table can be queried by user_id to find their list of games, by game_id to find the users in a game, or both to find out if a user is present in a game.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a game using Irrlicht. And I have problem. I have game in
I have a game made in cocos2d for iPhone, I've adapted for iPad and
I have a game which displays an array of colored blocks. The user can
I have a game in progress where the player can only move left and
I have a game using OpenGL. I've built off of the examples, for the
I have a game server than can take requests from a user. A user
I have a game where I am using 12 buttons with no text on
I have a game in which you can score from -40 to +40 on
I have a game built on xcode using objective c. this game needs to
I have game objects in an array collection, but they can be different classes.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.