[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

MySQL for race results

Posted on 2015-01-31
3
Medium Priority
?
392 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 80

Assisted Solution

by:arnold
arnold earned 2000 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 80

Accepted Solution

by:
arnold earned 2000 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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

In this article, I’ll talk about multi-threaded slave statistics printed in MySQL error log file.
An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

650 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