How should my database structure be?

Discussion in 'PHP' started by baris22, Feb 19, 2009.

  1. #1
    I am planning to make a very simple betting site. There will be only home, away and draw option for everyweek games.

    I could not figure it out the database structure.

    any suggestion?

    thanks
     
    baris22, Feb 19, 2009 IP
  2. crivion

    crivion Notable Member

    Messages:
    1,669
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    210
    Digital Goods:
    3
    #2
    wtb putting
    id, teamid, home, away, draw fields and user enum for home away and draw with values '0', '1'
    and when its 0 = false and when its 1 means thats true
    so for ex.
    id teamid home away draw
    1 445 0 x 0
    means that away was checked
    goodluck
     
    crivion, Feb 19, 2009 IP
  3. baris22

    baris22 Active Member

    Messages:
    543
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #3
    What about the weekly games.
    Team A will play with team B

    how will i do this?

    Thanks
     
    baris22, Feb 19, 2009 IP
  4. plog

    plog Peon

    Messages:
    298
    Likes Received:
    11
    Best Answers:
    1
    Trophy Points:
    0
    #4
    Everything is simple when you don't have to worry about the details. Work backwards and then worry about the structure.

    First,--what do you want to know? Make a list. If you have the web page already laid out and now what the results will look like, use that. As for the actual data you will need, obviously who played who, what team was home, which was away and who won. But also, do you want the date of each game played? Score? What data do you want to keep with each team? At least the name, but is there anything else like league, division, coach name, location? Also, will you be keeping track of multiple sports? Football and baseball and roller-derby? If so, that just added a new level of complexity.

    Take that list and turn it into a spreadsheet. Across the top make all the pieces of data headers, then underneath that construct a fake set of data. Just a couple of rows to make sure that the data you will be collecting has everything you need.

    Lastly, take the spreadsheet and turn it into a database system. Look up normalization or post back any questions you have once you decide what data you want to collect.
     
    plog, Feb 19, 2009 IP
  5. baris22

    baris22 Active Member

    Messages:
    543
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #5
    Does this look ok.

    Teams
    id
    team id
    team name

    Games
    id
    game id
    week id
    start time
    home team
    away team

    Users
    id
    user id
    user name
    pass

    Bet
    id
    bet id
    user id
    week id
    game id
    home
    away
    draw

    Results
    id
    result id
    week id
    game id
    home
    away
    draw

    Correct
    id
    correct id
    week no
    user id
    total


    Thanks
     
    baris22, Feb 20, 2009 IP