Solved

MySQL for race results

Posted on 2015-01-31
3
349 Views
Last Modified: 2015-02-06
I want to create a MySQL database to hold the results of a race that will take place annually.

The details I want in the table are:-
surname, firstname, racenumber, finishtime, year

Each year, runners will be issued a unique race (bib) number. However, the same set of numbers will be used each year.

What is the best way of keeping the racenumber field unique for each year? (i.e. racenumber must be a unique number between 1 and 200 for year 2015, and then again must be a unique number between 1 and 200 for year 2016 etc)
0
Comment
Question by:Chris Millard
  • 2
3 Comments
 
LVL 78

Assisted Solution

by:arnold
arnold earned 500 total points
ID: 40581431
What is the app you use to access the mysql, that is where you would randomize the assignment.
Presumably you a second table that has
Runnerid from the main runner info table
Year of the run
Runner number
All three will be added as a unique index. This will insure that there will not be two runner ers in a year with the same number enforced by the database.
Runner table
Year and number table.

Alternatively, you can assign a number to the individual in the order they are signed in.
That will insure uniqueness as well. First person to check in/sign in or be checked in/signed in will be 1 and the last will be 200
You could alternate the order year to year if you want, start from one and increment or start from 200 and decrement by changing the increment for the table.
0
 
LVL 78

Accepted Solution

by:
arnold earned 500 total points
ID: 40581432
The runner, year, race number table can include the results for the race, if you need to keep track of the time in various locations, another table could do that.
0
 
LVL 17

Author Closing Comment

by:Chris Millard
ID: 40593363
Thanks for the ideas - I haven't made a decision yet, as I have just over a year in order to finalise everything.
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
These days, all we hear about hacktivists took down so and so websites and retrieved thousands of user’s data. One of the techniques to get unauthorized access to database is by performing SQL injection. This article is quite lengthy which gives bas…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Viewers will learn how the fundamental information of how to create a table.

680 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question