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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:37:59+00:00 2026-06-16T04:37:59+00:00

I have a table of baseball stats, something like this: CREATE TABLE batting_stats( ab

  • 0

I have a table of baseball stats, something like this:

CREATE TABLE batting_stats(
    ab                INTEGER,
    pa                INTEGER,
    r                 INTEGER,
    h                 INTEGER,
    hr                INTEGER,
    rbi               INTEGER,
    playerID          INTEGER,
    FOREIGN KEY(playerID) REFERENCES player(playerID)
);

But then I have a table of stats that are basically exactly the same, but for a team:

CREATE TABLE team_batting_stats(
    ab                INTEGER,
    pa                INTEGER,
    r                 INTEGER,
    h                 INTEGER,
    hr                INTEGER,
    rbi               INTEGER,
    teamID            INTEGER,
    FOREIGN KEY(teamID) REFERENCES team(teamID)
);

My first instinct is to scrap the Foreign key and generalize the ID, but I still have a problem, I have these 2 tables, and they can’t have overlapping IDs:

CREATE TABLE player(
    playerID    INTEGER PRIMARY KEY,
    firstname   TEXT,
    lastname    TEXT,
    number      INTEGER,
    teamID      INTEGER,
    FOREIGN KEY(teamID) REFERENCES team(teamID)
);

CREATE TABLE team(
    teamID      INTEGER PRIMARY KEY,
    name        TEXT,
    city        TEXT,
);

I feel like I’m overlooking something obvious that could solve this problem and reduce stats to a single table.

  • 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-16T04:38:00+00:00Added an answer on June 16, 2026 at 4:38 am

    If you want to reduce the stats to a single table, you can add a couple of relationship tables to link either a batter or a team to the stats table.

    Entity tables:

    CREATE TABLE stats(
        statsID          INTEGER primary key,
        ab                INTEGER,
        pa                INTEGER,
        r                 INTEGER,
        h                 INTEGER,
        hr                INTEGER,
        rbi               INTEGER
    );
    
    CREATE TABLE player(
        playerID    INTEGER PRIMARY KEY,
        firstname   TEXT,
        lastname    TEXT,
        number      INTEGER,
        teamID      INTEGER,
        FOREIGN KEY(teamID) REFERENCES team(teamID)
    );
    
    CREATE TABLE team(
        teamID      INTEGER PRIMARY KEY,
        name        TEXT,
        city        TEXT,
    );
    

    Relationship tables that link batters/ teams to stats:

    CREATE TABLE batting_stats(
        playerID integer not null REFERENCES player(playerID),
        statsID integer not null REFERENCES stats(statsID),
        primary key (playerID, statsID)
    );
    
    CREATE TABLE team_batting_stats(
        teamID integer not null REFERENCES team(teamID),
        statsID integer not null REFERENCES stats(statsID),
        primary key (teamID, statsID)
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have table structure like this: ID cond 1 5 1 2 1 6
I have table data like this id id1 name 1 1 test1 1 1
I have table as below personalInfo CREATE TABLE personalInfo(userid BIGINT AUTO_INCREMENT PRIMARY KEY) patentInfo
i have table category the format is like this |id|parent_id|name| |1 |0 |sport| |2
I have table and this table contain result column with some entries. I just
I have table with 300 000 records (MyISAM). I get record from this table
I have table with two columns (varchar from, varchar to). This table represents connections
THIS IS USING MYSQL My question is the following. I have a baseball database,
I have table cars: Id int, Model nvarchar(max), DateOfProduction (datetime). And data like: 1
i have table (MEN) with 900,000 records. in this table i have field IP

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.