I am creating a database that will help you keep track of which employees were on a particular training course. I would like to get some recommendations on the best way to design a database.
In particular, every employee should attend the training course every year, and my database should keep a history of all the dates on which they attend the course in the past.
The end user will use the software as a planning tool to help them reserve dates for future courses for employees. When they select this employee, they will see:
- (a) Date of last visit
- (b) The forecast date of future attendance (i.e., the last date of presence + 1 calendar year)
From the point of view of my database, any employee can have several past visits to courses:
EmpName AttandanceDate Joe Bloggs 1st Jan 2007 Joe Bloggs 4th Jan 2008 Joe Bloggs 3rd Jan 2009 Joe Bloggs 8th Jan 2010
My question is the best way to set up a database to make it easier to get the latest course attendance? In the above example, the most recent would be January 8, 2010.
Is there a good way to use SQL to sort by date and select a MAX date?
My other idea was to add a column named "MostRecent" and just set the value to "TRUE".
EmpName AttandanceDate MostRecent Joe Bloggs 1st Jan 2007 False Joe Bloggs 4th Jan 2008 False Joe Bloggs 3rd Jan 2009 False Joe Bloggs 8th Jan 2010 True
I wondered if this would simplify SQL ie
SELECT Joe Bloggs WHERE MostRecent = 'TRUE'
In addition, when a user updates the attendance data of each employee (i.e. with the last date of visit), I could use SQL to:
- Find an Employee and Set MostRecent to FALSE
- Add a new entry with the MostRecent parameter to TRUE?
Would anyone recommend a method differently? Or do you have a completely different way to solve this problem?