dpw50696 2016-02-01 22:03
浏览 52
已采纳

构建数据库抽奖网站的有效方法[关闭]

I'm planning to make some kind of a raffle site as part of some gaming site. Now I was brainstorming about the best way to structure the database where the different raffles are stored. So my idea is to create a row for each raffle and give each ticketnumber its own column (which will hold the userid of the owner of the ticket). But as a raffle can get up to 1500 tickets I doubt if this is the best way to structure the table. Does anyone has another (better) suggestion how to do this or is this the best way?

  • 写回答

1条回答 默认 最新

  • douxidang9092 2016-02-01 22:14
    关注

    I would suggest having two tables. One called raffle which holds the raffle information for the current raffle and one called raffle_ticket holding the ticket information for the raffles. Here is the following structure I propose:

    raffle columns:

    • raffle_id (Auto increment primary key)
    • raffle_name (Raffle name)
    • raffle_date (date of raffle)
    • .... Other raffle information

    raffle_ticket columns:

    • raffle_ticket_id (Auto increment primary key)
    • raffle_id (Foreign key linking to the raffle_id in the raffle table)
    • raffle_user_id (Foreign key linking to the user_id in your user table)
    • raffle_num (The number of the ticket in the current raffle (Can be generated with SELECT MAX(raffle_num)+1 as newrafflenumber FROM raffle_ticket WHERE raffle_id = CURRENT_RAFFLE_ID; if you want sequential numbers per raffle)

    You may need something slightly different, but that's what I would suggest.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 树莓派与pix飞控通信
  • ¥15 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题