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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:11:10+00:00 2026-06-14T04:11:10+00:00

I have been over this issue for the last year or so, changing what

  • 0

I have been over this issue for the last year or so, changing what I am doing and trying different things. The issue is to do with the schema so I can still order nicely in player/clan ladders but if we want to add a stat later it won’t lock our table changing every row due to one stat per column.

I see two options for how to do this but both don’t seem to be right. One is one stat per column. There would be 4 tables, user_stat_summary (for basic stats shown on ladders), user_stat_beast (teams are human vs beast), user_stat_human and user_stat_overall. Stats are shown everywhere from the last 30 days. A cron job will take any dated stats by getting a query on matches that happened after the 30 days and taking away those stats from the 3 main tables and putting them into the overall one. Matches will have blobs for the stats each player got for that match. The issue I see here is when we have a lot of rows that we can’t easily add more stats when say the game changes a little. What I was thinking was a extra_stats blob column on each table and if we add new stats they simply aren’t going to be sortable on the ladders.

The other option is an EAV model which is what I have been playing around with but can’t seem to get it right. I would be getting many more rows per query and then grouping them into users and the order would work for the most part but I couldn’t get limits right for pagination since there was generally an unknown number of rows selected.

What I was thinking is the EAV model with a table that stores ranks per stats which could be used for ordering. So the EAV tables are currently as follows…

CREATE TABLE `user_stat` (
    `user_id` int(10) unsigned NOT NULL,
    `stat_id` varchar(50) NOT NULL,
    `value` int(10) unsigned NOT NULL,
    PRIMARY KEY (`user_id`,`stat_id`),
    CONSTRAINT `user` FOREIGN KEY (`user_id`) REFERENCES `xf_user` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8

CREATE TABLE `user_human_stat` (
     `user_id` int(10) unsigned NOT NULL,
     `stat_id` varchar(50) NOT NULL,
     `value` int(10) unsigned NOT NULL,
     PRIMARY KEY (`user_id`,`stat_id`),
     CONSTRAINT `human_user` FOREIGN KEY (`user_id`) REFERENCES `xf_user` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8

CREATE TABLE `user_beast_stat` (
     `user_id` int(10) unsigned NOT NULL,
     `stat_id` varchar(50) NOT NULL,
     `value` int(10) unsigned NOT NULL,
     PRIMARY KEY (`user_id`,`stat_id`),
     CONSTRAINT `beast_user` FOREIGN KEY (`user_id`) REFERENCES `xf_user` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8

CREATE TABLE `user_stat_overall` (
     `user_id` int(10) unsigned NOT NULL,
     `human` blob NOT NULL,
     `beast` blob NOT NULL,
     `total` blob NOT NULL,
     PRIMARY KEY (`user_id`),
     CONSTRAINT `user_overall` FOREIGN KEY (`user_id`) REFERENCES `xf_user` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8

So I was thinking I could add a user_stat_rank table which would be user_id, stat_id, rank. Then say I want to get the first page of the ladder ordered by the ‘kills’ stat I could get all the user_ids order by rank where stat_id is kills. Then make a second query to populate all the users stats.

After writing all this out it seems like it would work fine but I might not be seeing something. I also understand this question is all over the place so if you would like me to edit in details at places just say so.

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

    For sake of managibility, I would stick to adding a column for every stat. In the long run, this will probably be the easiest way to manage it without ending up in a corner due to the limitations that for instance the EAV model would impose on you.

    If you’re worried about the stats table growing too large, you could consider implementing some form of table partitioning where you regularly move the data older than 4 weeks to (a) historic table(s). The historic table(s) can be indexed to the extreme, as they won’t require constant updating.

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

Sidebar

Related Questions

I have been reading all over the web about this and still can't understand
I am starting to pull my hair out over this! I have been trying
I've been tearing my hair out over this issue for the last hour or
I have been going nuts over this issue for some time and I am
I have been learning about move constructors over the last day or so, trying
I have been looking over this code for the past hour, I cant see
I have been looking all over for this. I have two seperate prpt files
I have been looking over the internet for a while about this, but it
This is a bit of a vague notion which I have been running over
I have been researching all over the internet about this, and unfortunately cannot find

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.