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

  • Home
  • SEARCH
  • 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 281485
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T05:12:26+00:00 2026-05-12T05:12:26+00:00

I am creating a database that tracks replays for a game. Each replay has

  • 0

I am creating a database that tracks replays for a game. Each replay has a different game mode that is either team-based gameplay or individual-based gameplay. Depending on the game mode, I want to record the winning team or the winning individual.

I have the following MySQL table that tracks rounds in the replay and the associated winner:

CREATE TABLE replay_rounds (
    replay_id INT UNSIGNED NOT NULL,
    round SMALLINT UNSIGNED NOT NULL,
    winning_player_id INT UNSIGNED,
    winning_team_id TINYINT UNSIGNED,
    FOREIGN KEY (replay_id) REFERENCES replays(id),
    FOREIGN KEY (replay_id, winning_player_id) REFERENCES replay_players(replay_id, player_id),
    FOREIGN KEY (winning_team_id) REFERENCES teams(id),
    PRIMARY KEY (replay_id, round))
CHARACTER SET=utf8
COLLATE=utf8_general_ci
ENGINE=InnoDB;

Using what I have now, if the game mode is team-based then I will set the winning_team_id for each round and set the winning_player_id to null. Likewise, if the game mode is individual-based, I will set the winning_team_id to null.

Performance-wise and in terms of best practice, is it all right to leave it like this? Is there a compelling reason to split this into a separate table for each game mode (even if there’s only two modes)? How about a hypothetical situation where game modes are constantly being added — would this be best resolved by creating a table for every new game mode?

  • 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-12T05:12:26+00:00Added an answer on May 12, 2026 at 5:12 am

    I would just have one winning_id (drop the individual winning ids for team and player) and an additional attribute for game_type_cd. This will be a lookup attribute that is a foreign key to a new table called GAME_TYPE_COES. Then all you need to do is fill in the winning_id and the game type. This will allow for an infinite amount of game types with only having to add data to the GAME_TYPE_CODEs table and not having to change the data structure.

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

Sidebar

Related Questions

im creating a database that records details from multiple forms and each form has
I am creating a database that will help keep track of which employees have
I'm creating a report that will take some data from one database (Company and
I'm creating and app that will rely on a database, and I have all
i'm creating a web app that's running on an Advantage Database server, not my
I am creating a web application that is accessing a SQLite database in the
I am creating a small application that will be deployed on Window. The database
I am creating a php backup script that will dump everything from a database
I have an ASPX page that is dynamically creating a gridview from a database
In considering languages to use in creating a web-application that interfaces with a database

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.