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

The Archive Base Latest Questions

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

Rank Table ID, Primary Key RANK, The rank or level, 1 being the highest

  • 0

Rank Table

  • ID, Primary Key
  • RANK, The rank or level, 1 being the highest and 3 the lowest
  • MIN_SCORE, The minimum amount of point or XP needed to reach the rank
  • NAME, The associated name of the rank

    Rank Table
    +----+------+-----------+-------------------------+
    | ID | RANK | MIN_SCORE |          NAME           |
    +----+------+-----------+-------------------------+
    |  1 |    1 |     18932 | Editor-in-Chief         |
    |  2 |    2 |     15146 | Senior Technical Writer |
    |  3 |    3 |     12116 | Senior Copywriter       |
    +----+------+-----------+-------------------------+
    

Ranking Table

  • ID, Primary Key
  • FK_MEMEBER_ID, Foreign Key to member’s Primary Key
  • FK_RANK, Foreign Key to Author Rank Table’s Rank column (top)
  • SCORE, The member’s current earned score or XP

    Ranking Table
    +-----+--------------+---------+-------+
    | ID  | FK_MEMBER_ID | FK_RANK | SCORE |
    +-----+--------------+---------+-------+
    |   1 |            1 |       1 | 17722 |
    |   2 |            2 |       2 | 16257 |
    |   3 |            3 |       3 | 12234 |
    +-----+--------------+---------+-------+
    

In my class I have stored the ranks — matching those in the Rank Table — and correlating minimum scores; RANK as key and MINIMUM_SCORE as value.

When a member’s score (XP) is updated (up/down) I want to test that updated score against the below array to determine if their rank needs updating too.

private $scores = array('3' => '12116', '2' => '15146', '1' => '18932',);

Using the updated score, how could I determine the correlating rank from the above array?

Everything is open to scrutiny, this is my first time creating a ranking system so I hope to get it right 🙂

  • 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-11T13:29:11+00:00Added an answer on June 11, 2026 at 1:29 pm

    Ok, so given these tables:

    Ranks
    +------+-----------+-------------------------+
    | RANK | MIN_SCORE |          NAME           |
    +------+-----------+-------------------------+
    |  1   |     18932 | Editor-in-Chief         |
    |  2   |     15146 | Senior Technical Writer |
    |  3   |     12116 | Senior Copywriter       |
    +------+-----------+-------------------------+
    
    Members
    +-----------+-------+
    | MEMBER_ID | SCORE |
    +-----------+-------+
    |     1     | 17722 |
    |     2     | 16257 |
    |     3     | 12234 |
    +-----+-------------+
    

    You can get a member plus their rank using:

    SELECT m.MEMBER_ID, r.NAME
    FROM Members m INNER JOIN Ranks r
    ON m.SCORE > r.MIN_SCORE -- Pick ranks that a user is eligible for
    WHERE MEMBER_ID = ?
    HAVING MAX(r.MIN_SCORE) -- Pick the rank with the highest score
    

    This allows you remove an entire table, which should make your code easier to maintain. Hopefully your rank table will be so small than it will always be in memory, but an index over both MIN_SCORE and RANK will probably be helpful.

    If you determine that this join is a performance problem (please don’t do this unless you’ve measured a performance problem), you can use a similar query to update ranks in the members table, assuming it has a RANK column:

    UPDATE Members
    SET RANK = (
        SELECT RANK
        FROM Ranks
        WHERE SCORE > MIN_SCORE
        AND MEMBER_ID = MEMBER_ID
        HAVING MAX(MIN_SCORE)
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose i have a mysql table name table with fields rank date id The
CREATE TABLE item ( link MEDIUMINT UNSIGNED PRIMARY KEY NOT NULL, title TEXT NOT
I have a table with (among other things) a name and a rank. I'd
I have a rank table and its schema is defined as rank(id, key,value) where
Say I have a table name rank ----------------------- John 1 Tit 3 Bernard 4
I have a table in SQLite database of Android which has a column RANK
I'm trying to determine a rank for each key in a hash against the
I have a table that's like this rank continuationofrow 1 row 2 row 3
Imagine the below table as A col1 col2 col3 rank 1 2 n 5
Let's say i have a simple table voting with columns id(primaryKey),token(int),candidate(int),rank(int). I want to

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.