Solved

MySQL for race results

Posted on 2015-01-31
3
320 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 76

Assisted Solution

by:arnold
arnold earned 500 total points
Comment Utility
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 76

Accepted Solution

by:
arnold earned 500 total points
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Shadow IT is coming out of the shadows as more businesses are choosing cloud-based applications. It is now a multi-cloud world for most organizations. Simultaneously, most businesses have yet to consolidate with one cloud provider or define an offic…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

743 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now