java数据库数据安全
中华雪碧 2013-03-01 02:50:57 比赛表 match
match_id mantch_name max_num
1 xxx杯比赛 100
2 AAA杯比赛 200
比赛报名表 match_register
register_id match_id user_id
1 1 002
报名的最大人数不能超过match.max_num.
我的做法:
在用户报名xxx杯比赛时
select count(*) from match_register where match_id=1
if(count(*)>=match.max_num)
return报名人数满,
else
insert into match_register.
集中报名时,报名人数还是会超出max_num。
数据库设计是否合理?怎么保证报名的最大人数不能超过match.max_num?