| | |
"Claim a slot" database design
Please support our Database Design advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Oct 2009
Posts: 2
Reputation:
Solved Threads: 0
I'm developing a web page for a friend that allows participants of a sports event to "claim" a slot in a 24 hour tennis marathon. The marathon has room for 24 x 4 participants.
My idea was to have a table with the columns "hour" [0-23], "time" and "name", and pre-fill that table with 4 rows for each hour that have empty time and names columns.
Then, when someone fills in the form stating his name and the hour he wants to play, I'd update the table using something like
and then I'd check PHP's mysql_affected_rows() to see if the slot was claimed successfully. Because if 5 people are trying to enroll for the same hour simultaneously, one of the attempts will have to fail.
I can't find a way to do this. So, my design is probably incorrect? Any suggestions how to tackle this? Thanks
Joris
My idea was to have a table with the columns "hour" [0-23], "time" and "name", and pre-fill that table with 4 rows for each hour that have empty time and names columns.
Then, when someone fills in the form stating his name and the hour he wants to play, I'd update the table using something like
sql Syntax (Toggle Plain Text)
UPDATE slots SET TIME = NOW(), name = "John Doe" WHERE HOUR=14 AND name="" BUT AT MOST 1 ROW
and then I'd check PHP's mysql_affected_rows() to see if the slot was claimed successfully. Because if 5 people are trying to enroll for the same hour simultaneously, one of the attempts will have to fail.
I can't find a way to do this. So, my design is probably incorrect? Any suggestions how to tackle this? Thanks
Joris
Last edited by peter_budo; 34 Days Ago at 5:58 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks)
![]() |
Similar Threads
- your ideas on database design??? (Database Design)
- Database design regarding two 'linking' tables (Database Design)
- Database Design for storing versions (Database Design)
- Database Design feedback (absolute beginner here :) (Database Design)
- Help with contact/mailing list database design... (Database Design)
- Database design - subtypes and instances of an entity (Database Design)
- Database Design - Supertypes and Subtypes (Database Design)
- Database Design Advice (MySQL)
Other Threads in the Database Design Forum
- Previous Thread: mysql to sqlite
- Next Thread: Database HELP....Logical and Conceptual Design
| Thread Tools | Search this Thread |
3d 7 64bit advertising apple application browser bulletin cart clocks collaboration community company component computer control css customer daniweb database datepart design designer desktop developer development dreamweaver ecology errors evaluation file firefox firmware game gamer gaming green havoc-arcade havocarcade html india install interface internet iphone iphone2.1 java joomla jvm layout leopard list mac macos marketing microsoft mysql news object osx panel patch patents photoshop playstation poll portfolio ps3 pwnage remote research review security seo sharepoint shopping site software sony sqlserver survey syntax template text trojan update user vb virus vulnerability web webdesigner website websitedesign websitedesigner websitedeveloper win windows xhtml xp






