How should my database structure be?

Discussion in 'Databases' started by baris22, Feb 20, 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


    Users
    id
    user id
    user name
    pass


    Teams
    id
    team id
    team name


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


    Bet
    id
    bet id
    user id
    week id
    game id
    home
    away
    draw
    home correct
    away correct
    draw correct
     
    baris22, Feb 20, 2009 IP
  2. bl4ckwolf

    bl4ckwolf Active Member

    Messages:
    216
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    53
    #2
    First of all, i would retrieve all the "id" in each table because of the redundancy. You put another id on each table.

    I would also put the team id into a user. In this case, a user can be part of one team. If you want a user to be inside multiple teams, make a table with userid, teamid.

    You have weekid in the table but we don't know what it is. Maybe you need a table for week with StartDate, EndDate.

    I would only put 1 field in the game table : result (1=home, 2=away, 3=draft)

    In the bet table, retrieve weekid because you have this info in the game table. Also, replace all the fields (home, away, draw, home correct, away correct, draw correct) by one : The bet (Ex : 1 = home, 2 = away, 3 draft)

    Hope this will help!
     
    bl4ckwolf, Feb 21, 2009 IP
  3. baris22

    baris22 Active Member

    Messages:
    543
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #3
    thank you for your reply. What about this one.

    Users
    id
    user name
    pass


    Teams
    id
    team name


    Week
    id
    week number
    Start time
    Finish time


    Games
    id
    week number
    home team
    away team
    home
    away
    draw


    Bet
    id
    user id
    week number
    game id
    home
    away
    draw
    home correct
    away correct
    draw correct


    I just want something very simple. On the admin panel I can get games table and according to scores i can just update home, away, draw and at the same time I can update on bet table home correct, away correct and draw correct.

    What do you think?
     
    baris22, Feb 24, 2009 IP
  4. bl4ckwolf

    bl4ckwolf Active Member

    Messages:
    216
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    53
    #4
    Hi,

    This is going better, and this model can work.

    If i was doing your database, i would still do this instead of having 3 or 6 field in bet and game table...

    You are on the good way!
     
    bl4ckwolf, Feb 24, 2009 IP
  5. baris22

    baris22 Active Member

    Messages:
    543
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #5
    if i do not have

    home correct
    away correct
    draw correct

    how will i know the user made the correct bet?

    When I update home, away, draw field ( after the game finished) from admin panel I can also update

    home correct
    away correct
    draw correct

    for each user.
     
    baris22, Feb 24, 2009 IP