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 3797652
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T13:26:15+00:00 2026-05-19T13:26:15+00:00

Assume the game has two players. Each player has a score and highest score

  • 0

Assume the game has two players. Each player has a score and highest score wins. A user table is self evident. The first design I thought of is as follows:

match_id, user1_id, user2_id, score1, score2

The problem is suppose I want a quick way of ranking users by win %. In the above table a single userid would be scattered between user1_id and user2_id. It would seem to require multiple queries and seems messy. The other way is to keep a separate stats table

user_id, winloss

This makes queries easy but doesn’t seem theoretically correct because the stats table stores derive data. Is there a way to solve this which involves a nice, clean theoretically correct data structure which is easy to query?

  • 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-05-19T13:26:16+00:00Added an answer on May 19, 2026 at 1:26 pm

    How about have one record for each user in a match? The primary key is then the combination of match_id and user_id. Also include a boolean winner field.

    match_id, user_id, score, winner

    Though not part of your requirement, this also easily scales up to more players.

    Querying win % is simply a matter of:

    SELECT winner, count(winner) FROM match_results
    WHERE user_id = (some_user) GROUP BY winner;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Support we have an n * m table, and two players play this game.
I have two vectors in a game. One vector is the player, one vector
Let's assume I'm developing a AJAX, PHP chess game. During the game, one movement
Assume a table structure of MyTable(KEY, datafield1, datafield2...) . Often I want to either
I am going to create game for android, this game has multiplayer mode, so
I created a Flash room editor for an online game. The user is able
I'm facing a problem which is probably extremely common in game-design. Let's assume that
Background I'm making a canvas game which assumes the user to be using a
I have a WP7 game that has symptoms similar to the following post: WP7
assume that i have two sequential methods, methodA and methodB ( methodB is called

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.