How do I organize tables for simple lottery game? mysql [closed]

Posted on

Question :

I am building a simple lottery web game that will let users pick a number that is in between that weeks given range. A number will be randomly select to determine the winner. I have a table for users (id, username, password, pin, funds) but as I go to setup the games table I get kinda stumped. How do I keep track of what numbers have been picked so far and who they belong to? game (id, date, winner…)? How do I handle the fact that the number range can change from week to week?

users

  • id
  • username
  • password
  • pin
  • funds

games

  • id
  • date
  • winner

number_range

  • date
  • range

selected_numbers

  • date
  • user_id
  • number

Is this heading in the right direction?

Answer :

I’d create another table to store the number range each week (store the date and range) and then another table to store the user’s selection (store the user id, date, and chosen number).

Leave a Reply

Your email address will not be published.