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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:03:36+00:00 2026-05-13T20:03:36+00:00

Just looking for some suggestions on how to approach the database design for this.

  • 0

Just looking for some suggestions on how to approach the database design for this.

On my site a user can get points for performing different activities. Currently there are 3 activities for which I award points – but the design has to be scalable where I can add other activities for awarding points as well.

So today – the user gets points
1) When he adds a new store he gets 10 points (Store information is stored in STORE table)
2) When he answers a question he gets 7 points (Questions/answers are stored in a ANSWERS table)
3) When he refers friends who join the site he gets 5 points

So this is what I have so far – but it doesnt look right 🙂

Points_Table
point_id
user_id
action (This will capture for what action the points are being given)
points

I should be able to deduce from the database that this user got xxxx points for creating this store or for referring these friends or for answering this question.
The above design obviously doesn’t take care of that.

Thanks for your tips

  • 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-13T20:03:37+00:00Added an answer on May 13, 2026 at 8:03 pm

    Don’t store the points at all. Just do queries on this view. That way it will be robust in the face of arbitrary changes.

    create view UserPoints
    as
    select
        created_by_id as user_id,
        'STORE' as action_type,
        store_id as action_id,
        (select points from action_points where action_desc='create store') as points
    from store
    union
    select
        user_id,
        'ANSWER' as action_type,
        question_id as action_id,
        (select points from action_points where action_desc='answer question') as points
    from answer
    union
    select
        referred_by_id as user_id,
        'REFERRAL' as action_type,
        referred_id as action_id,
        (select points from action_points where action_desc='referral') as points
    from referral
    

    Edited to add:

    This follows the normal database design principles. All database normalization can be summed up with this: don’t repeat data.

    The inclusion of a points table essentially just repeats information that the rest of the database already contains. Therefore, it should be omitted. This is made clear when considering the lengths to which one must go to maintain the consistency of the data. Without worrying about the points, if a referral is attributed to Alice, but later it is determined that Bob should receive the credit, this will require a change to a single field in a single row of a single table. If a points table is included, then it must also be updated in some way. If points summaries are being stored, then may God have mercy on your database.

    Rather than storing the points, a view or stored procedure may be used instead, and then the points system is adjusted automatically when the data changes.

    I think a view is perferrable to a stored procedure in this case, because there are many ways in which the points data may need to be analyzed, and this provides the most flexibility, and it gives the optimizer the best chance at identifying the optimal path.

    You may select from the view by user_id or by action_type or sum the points column to get totals for a user or for all users. Look at the fun you can have, and it’s practically free!

    select
        sum(up.points) as total_points,
        up.user_id,
        u.user_name
    from
        UserPoints up
        join user u on up.user_id = u.user_id
    group by
        user_id,
        user_name
    order by
        total_points desc
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone have some numbers on this? I am just looking for a percentage,
I've done some Googling, and can't find anything, though maybe I'm just looking in
I'm just starting to design some embedded devices, and am looking for resources. What
I was just looking through some information about Google's protocol buffers data interchange format.
Just some days ago I started looking into a unit test framework called check,
I just (re-)joined a company to work on some C++ projects. I'm looking at
Just looking at: (Source: https://xkcd.com/327/ ) What does this SQL do: Robert'); DROP TABLE
Just looking for the first step basic solution here that keeps the honest people
Just looking at ways of getting named constants in python. class constant_list: (A_CONSTANT, B_CONSTANT,
Just looking for the relevant documentation. An example is not necessary, but would be

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.